def start_transfer(context, read_file_handle, data_size, write_file_handle=None, image_service=None, image_id=None, image_meta=None):
 if (not image_meta):
  image_meta = {}
 thread_safe_pipe = io_util.ThreadSafePipe(QUEUE_BUFFER_SIZE, data_size)
 read_thread = io_util.IOThread(read_file_handle, thread_safe_pipe)
 if write_file_handle:
  write_thread = io_util.IOThread(thread_safe_pipe, write_file_handle)
 elif (image_service and image_id):
  write_thread = io_util.GlanceWriteThread(context, thread_safe_pipe, image_service, image_id, image_meta)
 read_event = read_thread.start()
 write_event = write_thread.start()
 try:
  read_event.wait()
  write_event.wait()
 except Exception as exc:
  read_thread.stop()
  write_thread.stop()
  LOG.exception(exc)
  raise exception.NovaException(exc)
 finally:
  read_file_handle.close()
  if write_file_handle:
   write_file_handle.close()

def start_transfer ( context , read_file_handle , data_size , write_file_handle = None , image_service = None , image_id = None , image_meta = None ) : if ( not image_meta ) : image_meta = { } thread_safe_pipe = io_util . ThreadSafePipe ( QUEUE_BUFFER_SIZE , data_size ) read_thread = io_util . IOThread ( read_file_handle , thread_safe_pipe ) if write_file_handle : write_thread = io_util . IOThread ( thread_safe_pipe , write_file_handle ) elif ( image_service and image_id ) : write_thread = io_util . GlanceWriteThread ( context , thread_safe_pipe , image_service , image_id , image_meta ) read_event = read_thread . start ( ) write_event = write_thread . start ( ) try : read_event . wait ( ) write_event . wait ( ) except Exception as exc : read_thread . stop ( ) write_thread . stop ( ) LOG . exception ( exc ) raise exception . NovaException ( exc ) finally : read_file_handle . close ( ) if write_file_handle : write_file_handle . close ( )
start the data transfer from the reader to the writer .