| 341 | def test_del_after_loop_close_does_not_raise(lock_type: type[BaseAsyncFileLock], tmp_path: Path) -> None: |
| 342 | # __del__ must not call get_running_loop() — it raises RuntimeError when no loop is running |
| 343 | def _run() -> None: |
| 344 | lock = lock_type(str(tmp_path / "test.lock")) |
| 345 | loop = asyncio.new_event_loop() |
| 346 | asyncio.set_event_loop(loop) |
| 347 | try: |
| 348 | loop.run_until_complete(lock.acquire()) |
| 349 | loop.run_until_complete(lock.release(force=True)) |
| 350 | finally: |
| 351 | loop.close() |
| 352 | asyncio.set_event_loop(None) |
| 353 | del lock |
| 354 | gc.collect() |
| 355 | |
| 356 | with ThreadPoolExecutor(max_workers=1) as pool: |
| 357 | pool.submit(_run).result(timeout=10) |