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

Method acquire

src/trio/_sync.py:518–529  ·  view source on GitHub ↗

Decrement the semaphore value, blocking if necessary to avoid letting it drop below zero.

(self)

Source from the content-addressed store, hash-verified

516
517 @enable_ki_protection
518 async def acquire(self) -> None:
519 """Decrement the semaphore value, blocking if necessary to avoid
520 letting it drop below zero.
521
522 """
523 await trio.lowlevel.checkpoint_if_cancelled()
524 try:
525 self.acquire_nowait()
526 except trio.WouldBlock:
527 await self._lot.park()
528 else:
529 await trio.lowlevel.cancel_shielded_checkpoint()
530
531 @enable_ki_protection
532 def release(self) -> None:

Callers 4

test_SemaphoreFunction · 0.95
__aenter__Method · 0.45
acquireMethod · 0.45
_move_elems_to_channelFunction · 0.45

Calls 2

acquire_nowaitMethod · 0.95
parkMethod · 0.80

Tested by 1

test_SemaphoreFunction · 0.76