| 219 | # The cache still finds a lock whose finalizer is starting, as another thread asking at that moment would. |
| 220 | # Interpreters run a profile hook with tracing off, so coverage does not record its body. |
| 221 | def take_from_cache(frame: FrameType, event: str, _arg: Unused) -> None: # pragma: no cover |
| 222 | if event == "call" and frame.f_code is BaseFileLock.__del__.__code__ and not handed_out: |
| 223 | handed_out.append( |
| 224 | AsyncFileLock(lock_path, is_singleton=True, thread_local=thread_local, run_in_executor=False) |
| 225 | ) |
| 226 | asyncio.run(handed_out[0].acquire()) |
| 227 | |
| 228 | sys.setprofile(take_from_cache) |
| 229 | try: |