code: def flush(self, multithread=True, **kwargs):
          '''
          Flushes the internal write buffer.
          '''
          if self._write_buf.tell() > 0:
              data = self._write_buf.getvalue()
              self._write_buf = BytesIO()
  
              if multithread:
                  self._async_upload_part_request(data, index=self._cur_part, **kwargs)
              else:
                  self.upload_part(data, self._cur_part, **kwargs)
  
              self._cur_part += 1
  
          if len(self._http_threadpool_futures) > 0:
              dxpy.utils.wait_for_all_futures(self._http_threadpool_futures)
              try:
                  for future in self._http_threadpool_futures:
                      if future.exception() != None:
                          raise future.exception()
              finally:
                  self._http_threadpool_futures = set(f flush(self, multithread=True, **kwargs):
          '''
          Flushes the internal write buffer.
          '''
          if self._write_buf.tell() > 0:
              data = self._write_buf.getvalue()
              self._write_buf = BytesIO()
  
              if multithread:
                  self._async_upload_part_request(data, index=self._cur_part, **kwargs)
              else:
                  self.upload_part(data, self._cur_part, **kwargs)
  
              self._cur_part += 1
  
          if len(self._http_threadpool_futures) > 0:
              dxpy.utils.wait_for_all_futures(self._http_threadpool_futures)
              try:
                  for future in self._http_threadpool_futures:
                      if future.exception() != None:
                          raise future.exception()
              finally:
                  self._http_threadpool_futures = set()
docs: Flushes the internal write buffer.