MCPcopy Create free account
hub / github.com/tox-dev/filelock / audit_hook

Function audit_hook

tests/sqlite/test_connection_descriptors.py:38–49  ·  view source on GitHub ↗
(  # pragma: no cover - interpreter audit hooks run with tracing disabled
        event: str, args: tuple[StrOrBytesPath, ...]
    )

Source from the content-addressed store, hash-verified

36
37 # Typed for the sqlite3.connect payload the hook reads; every other event returns before touching args.
38 def audit_hook( # pragma: no cover - interpreter audit hooks run with tracing disabled
39 event: str, args: tuple[StrOrBytesPath, ...]
40 ) -> None:
41 nonlocal connection_events
42 if event != "sqlite3.connect":
43 return
44 database = args[0]
45 # The lock connects by its own path, or through a private hard link where others share its directory.
46 if isinstance(database, (str, bytes)) and (
47 (path := os.fsdecode(database)) == str(lock_path) or Path(path).parent.parent.name.startswith(".filelock-")
48 ):
49 connection_events += 1
50
51 sys.addaudithook(audit_hook)
52 lock = ReadWriteLock(lock_path, is_singleton=False)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected