@contextlib.contextmanager
def multimap(cores=None):
 if (cores is None):
  cores = max((multiprocessing.cpu_count() - 1), 1)
 def wrapper(func):
  def wrap(self, timeout=None):
   return func(self, timeout=(timeout if (timeout is not None) else 1e+100))
  return wrap
 IMapIterator.next = wrapper(IMapIterator.next)
 pool = multiprocessing.Pool(cores)
 (yield pool.imap)
 pool.terminate()

@ contextlib . contextmanager def multimap ( cores = None ) : if ( cores is None ) : cores = max ( ( multiprocessing . cpu_count ( ) - 1 ) , 1 ) def wrapper ( func ) : def wrap ( self , timeout = None ) : return func ( self , timeout = ( timeout if ( timeout is not None ) else 1e+100 ) ) return wrap IMapIterator . next = wrapper ( IMapIterator . next ) pool = multiprocessing . Pool ( cores ) ( yield pool . imap ) pool . terminate ( )
provide multiprocessing imap like function .