MCPcopy Create free account
hub / github.com/tox-dev/filelock / closing_worker

Function closing_worker

tests/async_lock/test_read_write_wait.py:266–287  ·  view source on GitHub ↗
(
    request: pytest.FixtureRequest, tmp_path: Path, make: _Make
)

Source from the content-addressed store, hash-verified

264
265@pytest_asyncio.fixture(loop_scope="function")
266async def closing_worker(
267 request: pytest.FixtureRequest, tmp_path: Path, make: _Make
268) -> AsyncIterator[tuple[AsyncReadWriteLock | AsyncSoftReadWriteLock, threading.Thread, threading.Event]]:
269 sync, lock = make(tmp_path, is_singleton=True)
270 if request.param == "retire":
271 await lock.acquire_write()
272 worker = await asyncio.wrap_future(lock.executor.submit(threading.current_thread))
273 resume = threading.Event()
274 lock.executor.submit(resume.wait, 5)
275 closing = asyncio.create_task(lock.close())
276 try:
277 await asyncio.sleep(0)
278 if request.param == "retry":
279 closing.cancel()
280 with pytest.raises(asyncio.CancelledError):
281 await closing
282 yield lock, worker, resume
283 finally:
284 resume.set()
285 with suppress(asyncio.CancelledError):
286 await closing
287 sync.close()

Callers

nothing calls this directly

Calls 5

submitMethod · 0.80
sleepMethod · 0.80
cancelMethod · 0.80
acquire_writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected