MCPcopy Index your code
hub / github.com/python/cpython / test_acquire_cancel

Method test_acquire_cancel

Lib/test/test_asyncio/test_locks.py:1015–1024  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1013 await asyncio.gather(*race_tasks)
1014
1015 async def test_acquire_cancel(self):
1016 sem = asyncio.Semaphore()
1017 await sem.acquire()
1018
1019 acquire = asyncio.create_task(sem.acquire())
1020 asyncio.get_running_loop().call_soon(acquire.cancel)
1021 with self.assertRaises(asyncio.CancelledError):
1022 await acquire
1023 self.assertTrue((not sem._waiters) or
1024 all(waiter.done() for waiter in sem._waiters))
1025
1026 async def test_acquire_cancel_before_awoken(self):
1027 sem = asyncio.Semaphore(value=0)

Callers

nothing calls this directly

Calls 7

acquireMethod · 0.95
SemaphoreMethod · 0.80
assertTrueMethod · 0.80
create_taskMethod · 0.45
call_soonMethod · 0.45
assertRaisesMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected