(worker_id, map_func, args, results_queue=None, init_ctx_func=None)
| 4 | |
| 5 | |
| 6 | def chunked_worker(worker_id, map_func, args, results_queue=None, init_ctx_func=None): |
| 7 | ctx = init_ctx_func(worker_id) if init_ctx_func is not None else None |
| 8 | for job_idx, arg in args: |
| 9 | try: |
| 10 | if ctx is not None: |
| 11 | res = map_func(*arg, ctx=ctx) |
| 12 | else: |
| 13 | res = map_func(*arg) |
| 14 | results_queue.put((job_idx, res)) |
| 15 | except: |
| 16 | traceback.print_exc() |
| 17 | results_queue.put((job_idx, None)) |
| 18 | |
| 19 | def chunked_multiprocess_run(map_func, args, num_workers=None, ordered=True, init_ctx_func=None, q_max_size=1000): |
| 20 | args = zip(range(len(args)), args) |
nothing calls this directly
no outgoing calls
no test coverage detected