def close(self, block=False, **kwargs):
        self.flush(**kwargs)

        # Also populates emptyLastPartAllowed
        #
        # TODO: only upload a zero-length part condition on
        # emptyLastPartAllowed
        self._ensure_write_bufsize()

        if self._num_uploaded_parts == 0:
            # We haven't uploaded any parts in this session. In case no parts have been uploaded at all, try to upload
            # an empty part (files with 0 parts cannot be closed).
            try:
                self.upload_part('', 1, **kwargs)
            except dxpy.exceptions.InvalidState:
                pass

        if 'report_progress_fn' in kwargs:
            del kwargs['report_progress_fn']

        dxpy.api.file_close(self._dxid, **kwargs)

        if block:
            self._wait_on_close(**kwargs)
:param block: If True, this function blocks until the remote file has closed.
dataset/ETHPy150Open dnanexus/dx-toolkit/src/python/dxpy/bindings/dxfile.py/DXFile.close