python - multiprocessing.Pool.map() not working as expected -


i understand simple examples pool.map supposed behave identically 'normal' python code below except in parallel:

def f(x): # complicated processing return x+1  y_serial = [] x = range(100) in x: y_serial += [f(x)] y_parallel = pool.map(f, x)  # y_serial == y_parallel! 

however have 2 bits of code believe should follow example:

#linear version price_datas = []  csv_file in loop_through_zips(data_directory):     price_datas += [process_bf_data_csv(csv_file)]  #parallel version p = pool() price_data_parallel = p.map(process_bf_data_csv, loop_through_zips(data_directory)) 

however parallel code doesn't work whereas linear code does. can observe, parallel version appears looping through generator (it's printing out log lines generator function) not performing "process_bf_data_csv" function. doing wrong here?

.map tries pull values generator form iterable before starting work. try waiting longer (till generator runs out) or use multi threading , queue instead.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -