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.
()
| 124 | |
| 125 | |
| 126 | def 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 |
searching dependent graphs…