| 40 | def test_del_after_loop_close_does_not_raise(lock_type: type[BaseAsyncFileLock], tmp_path: Path) -> None: |
| 41 | # __del__ must not call get_running_loop(); it raises RuntimeError when no loop is running |
| 42 | def _run() -> None: |
| 43 | lock = lock_type(str(tmp_path / "test.lock")) |
| 44 | loop = asyncio.new_event_loop() |
| 45 | asyncio.set_event_loop(loop) |
| 46 | try: |
| 47 | loop.run_until_complete(lock.acquire()) |
| 48 | loop.run_until_complete(lock.release(force=True)) |
| 49 | finally: |
| 50 | loop.close() |
| 51 | asyncio.set_event_loop(None) |
| 52 | del lock |
| 53 | gc.collect() |
| 54 | |
| 55 | with ThreadPoolExecutor(max_workers=1) as pool: |
| 56 | pool.submit(_run).result(timeout=10) |