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

Method release_on_behalf_of

src/trio/_sync.py:398–411  ·  view source on GitHub ↗

Put a token back into the sack on behalf of ``borrower``. Raises: RuntimeError: if the given borrower has not acquired one of this sack's tokens.

(self, borrower: Task | object)

Source from the content-addressed store, hash-verified

396
397 @enable_ki_protection
398 def release_on_behalf_of(self, borrower: Task | object) -> None:
399 """Put a token back into the sack on behalf of ``borrower``.
400
401 Raises:
402 RuntimeError: if the given borrower has not acquired one of this
403 sack's tokens.
404
405 """
406 if borrower not in self._borrowers:
407 raise RuntimeError(
408 "this borrower isn't holding any of this CapacityLimiter's tokens",
409 )
410 self._borrowers.remove(borrower)
411 self._wake_waiters()
412
413 def statistics(self) -> CapacityLimiterStatistics:
414 """Return an object containing debugging information.

Callers 6

releaseMethod · 0.95
test_CapacityLimiterFunction · 0.95
to_thread_run_syncFunction · 0.45

Calls 2

_wake_waitersMethod · 0.95
removeMethod · 0.45