()
| 122 | @pytest.mark.parametrize("shut_down", [pytest.param(False, id="available"), pytest.param(True, id="shut-down")]) |
| 123 | def test_close_leaves_the_default_executor_idle(lock_file: str, *, shut_down: bool) -> None: |
| 124 | async def run() -> None: |
| 125 | started = threading.Event() |
| 126 | loop = asyncio.get_running_loop() |
| 127 | loop.set_default_executor(ThreadPoolExecutor(max_workers=1, initializer=started.set)) |
| 128 | lock = AsyncReadWriteLock(lock_file, is_singleton=False) |
| 129 | worker = await asyncio.wrap_future(lock.executor.submit(threading.current_thread)) |
| 130 | if shut_down: |
| 131 | await loop.shutdown_default_executor() |
| 132 | await lock.close() |
| 133 | |
| 134 | assert not worker.is_alive() |
| 135 | assert not started.is_set() |
| 136 | |
| 137 | asyncio.run(run()) |
| 138 |
no test coverage detected