MCPcopy
hub / github.com/pandas-dev/pandas / run_multithreaded

Function run_multithreaded

pandas/_testing/__init__.py:540–567  ·  view source on GitHub ↗
(closure, max_workers, arguments=None, pass_barrier=False)

Source from the content-addressed store, hash-verified

538
539
540def run_multithreaded(closure, max_workers, arguments=None, pass_barrier=False):
541 with ThreadPoolExecutor(max_workers=max_workers) as tpe:
542 if arguments is None:
543 arguments = []
544 else:
545 arguments = list(arguments)
546
547 if pass_barrier:
548 barrier = threading.Barrier(max_workers)
549 arguments.append(barrier)
550
551 try:
552 futures = []
553 for _ in range(max_workers):
554 futures.append(tpe.submit(closure, *arguments)) # noqa: PERF401
555 except RuntimeError as e:
556 import pytest
557
558 pytest.skip(
559 f"Spawning {max_workers} threads failed with "
560 f"error {e!r} (likely due to resource limits on the "
561 "system running the tests)"
562 )
563 finally:
564 if len(futures) < max_workers and pass_barrier:
565 barrier.abort()
566 for f in futures:
567 f.result()
568
569
570__all__ = [

Callers

nothing calls this directly

Calls 2

appendMethod · 0.45
resultMethod · 0.45

Tested by

no test coverage detected