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

Method test_acquire_cancel

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

Source from the content-addressed store, hash-verified

135 self.assertTrue(t3.result())
136
137 async def test_acquire_cancel(self):
138 lock = asyncio.Lock()
139 self.assertTrue(await lock.acquire())
140
141 task = asyncio.create_task(lock.acquire())
142 asyncio.get_running_loop().call_soon(task.cancel)
143 with self.assertRaises(asyncio.CancelledError):
144 await task
145 self.assertFalse(lock._waiters)
146
147 async def test_cancel_race(self):
148 # Several tasks:

Callers

nothing calls this directly

Calls 7

acquireMethod · 0.95
LockMethod · 0.80
assertTrueMethod · 0.80
assertFalseMethod · 0.80
create_taskMethod · 0.45
call_soonMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected