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

Function current_default_thread_limiter

src/trio/_threads.py:126–139  ·  view source on GitHub ↗

Get the default `~trio.CapacityLimiter` used by `trio.to_thread.run_sync`. The most common reason to call this would be if you want to modify its :attr:`~trio.CapacityLimiter.total_tokens` attribute.

()

Source from the content-addressed store, hash-verified

124
125
126def current_default_thread_limiter() -> CapacityLimiter:
127 """Get the default `~trio.CapacityLimiter` used by
128 `trio.to_thread.run_sync`.
129
130 The most common reason to call this would be if you want to modify its
131 :attr:`~trio.CapacityLimiter.total_tokens` attribute.
132
133 """
134 try:
135 limiter = _limiter_local.get()
136 except LookupError:
137 limiter = CapacityLimiter(DEFAULT_LIMIT)
138 _limiter_local.set(limiter)
139 return limiter
140
141
142# Eventually we might build this into a full-fledged deadlock-detection

Calls 3

CapacityLimiterClass · 0.85
getMethod · 0.45
setMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…