MCPcopy Create free account
hub / github.com/GerevAI/gerev / parse_with_workers

Function parse_with_workers

app/data_source/api/utils.py:30–43  ·  view source on GitHub ↗
(method_name: callable, items: list, **kwargs)

Source from the content-addressed store, hash-verified

28
29
30def parse_with_workers(method_name: callable, items: list, **kwargs):
31 workers = 10 # should be a config value
32
33 logger.info(f'Parsing {len(items)} documents using {method} (with {workers} workers)...')
34
35 with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
36 futures = []
37 for i in range(workers):
38 futures.append(executor.submit(_wrap_with_try_except(method), items[i::workers], **kwargs))
39 concurrent.futures.wait(futures)
40 for w in futures:
41 e = w.exception()
42 if e:
43 logging.exception("Worker failed", exc_info=e)
44
45
46@lru_cache(maxsize=512)

Callers

nothing calls this directly

Calls 1

_wrap_with_try_exceptFunction · 0.85

Tested by

no test coverage detected