MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / chunked_worker

Function chunked_worker

utils/multiprocess_utils.py:6–17  ·  view source on GitHub ↗
(worker_id, map_func, args, results_queue=None, init_ctx_func=None)

Source from the content-addressed store, hash-verified

4
5
6def 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
19def 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)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected