()
| 356 | |
| 357 | |
| 358 | def _reentrant_finalizer_script() -> str: # pragma: needs fork |
| 359 | return textwrap.dedent( |
| 360 | """ |
| 361 | from __future__ import annotations |
| 362 | |
| 363 | import asyncio |
| 364 | import gc |
| 365 | import sys |
| 366 | import weakref |
| 367 | from threading import Condition, Event |
| 368 | from types import CodeType, FrameType |
| 369 | from typing import Final |
| 370 | |
| 371 | from filelock import AsyncReadWriteLock, ReadWriteLock |
| 372 | |
| 373 | class _FinalizerTarget: |
| 374 | cycle: _FinalizerTarget |
| 375 | |
| 376 | _FINALIZED: Final[Event] = Event() |
| 377 | |
| 378 | def _close_lock() -> None: |
| 379 | ReadWriteLock(sys.argv[2], is_singleton=False).close() |
| 380 | _FINALIZED.set() |
| 381 | |
| 382 | _TARGET = _FinalizerTarget() |
| 383 | _TARGET.cycle = _TARGET |
| 384 | weakref.finalize(_TARGET, _close_lock) |
| 385 | del _TARGET |
| 386 | |
| 387 | _NOTIFY_CODE: Final[CodeType] = Condition.notify_all.__code__ |
| 388 | |
| 389 | def _collect_at_notify(frame: FrameType, _event: str, _argument: None) -> None: |
| 390 | if frame.f_code is _NOTIFY_CODE: |
| 391 | sys.settrace(None) |
| 392 | gc.collect() |
| 393 | |
| 394 | sys.settrace(_collect_at_notify) |
| 395 | _LOCK: Final[AsyncReadWriteLock] = AsyncReadWriteLock(sys.argv[1], is_singleton=False) |
| 396 | sys.settrace(None) |
| 397 | |
| 398 | assert _FINALIZED.is_set() |
| 399 | asyncio.run(_LOCK.close()) |
| 400 | """ |
| 401 | ) |
| 402 | |
| 403 | |
| 404 | def _recursive_construction_script() -> str: |
no outgoing calls
no test coverage detected