task_id = 0 for i in range(len(strategy_args)): args = strategy_args[i] for day in days: task = {'strategy_id': i, 'strategy_args': args, 'day': day.timetuple()[:3], 'ticker': ticker_details, 'task_id': task_id} tasks[task_id] = task task_id += 1 # put the tasks in the queue queue.putmany(tasks.values()) print "%s: start analyzing %s tasks" % (str(datetime.now()), len(tasks)) for i in range(len(tasks)): result_dict = result.get() for task_id, report in result_dict.items(): tsk = tasks.get(task_id) tsk.update({'report': report}) print "analyzed task: %s" % task_id p1.stop(); p2.stop() p1.join(); p2.join() # store the pickled tasks in a file for later analysis fname = "../simulations/first_run_%s" % start_time.strftime("%Y%m%d%H%M%S") f = open(fname, 'w') pickle.dump(tasks, f, pickle.HIGHEST_PROTOCOL) f.close() print "output written to: %s" % fname