def parallel_bulk(client, actions, thread_count=4, chunk_size=500, max_chunk_bytes=((100 * 1024) * 1024), expand_action_callback=expand_action, **kwargs):
 from multiprocessing.dummy import Pool
 actions = map(expand_action_callback, actions)
 pool = Pool(thread_count)
 try:
  for result in pool.imap((lambda chunk: list(_process_bulk_chunk(client, chunk, **kwargs))), _chunk_actions(actions, chunk_size, max_chunk_bytes, client.transport.serializer)):
   for item in result:
    (yield item)
 finally:
  pool.close()
  pool.join()

def parallel_bulk ( client , actions , thread_count = 4 , chunk_size = 500 , max_chunk_bytes = ( ( 100 * 1024 ) * 1024 ) , expand_action_callback = expand_action , ** kwargs ) : from multiprocessing . dummy import Pool actions = map ( expand_action_callback , actions ) pool = Pool ( thread_count ) try : for result in pool . imap ( ( lambda chunk : list ( _process_bulk_chunk ( client , chunk , ** kwargs ) ) ) , _chunk_actions ( actions , chunk_size , max_chunk_bytes , client . transport . serializer ) ) : for item in result : ( yield item ) finally : pool . close ( ) pool . join ( )
parallel version of the bulk helper run in multiple threads at once .