MCPcopy
hub / github.com/python-trio/trio / _track_active_thread

Function _track_active_thread

src/trio/_threads.py:70–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68
69@contextlib.contextmanager
70def _track_active_thread() -> Generator[None, None, None]:
71 try:
72 active_threads_local = _active_threads_local.get()
73 except LookupError:
74 active_threads_local = _ActiveThreadCount(0, Event())
75 _active_threads_local.set(active_threads_local)
76
77 active_threads_local.count += 1
78 try:
79 yield
80 finally:
81 active_threads_local.count -= 1
82 if active_threads_local.count == 0:
83 active_threads_local.event.set()
84 active_threads_local.event = Event()
85
86
87async def wait_all_threads_completed() -> None:

Callers 1

to_thread_run_syncFunction · 0.85

Calls 4

_ActiveThreadCountClass · 0.85
EventClass · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…