mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-10 17:16:36 +00:00
fix(vegas): tell code the gate must not park in by module name, not path
The gate never parks a thread inside logging, threading, importlib or the cache, and it matched those as substrings of each frame's file path. On GitHub's runners Python lives under /opt/hostedtoolcache, so every stdlib frame said "cache" and the gate never parked anything -- three tests failed there and passed here. A virtualenv under ~/.cache would have done the same on a Pi. Match the frame's module name (f_globals['__name__']) instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-13
@@ -67,15 +67,16 @@ STALE_SECONDS = 0.05
|
||||
#: Swaps needed before the refresh period is trusted enough to open a window.
|
||||
MIN_SAMPLES = 8
|
||||
|
||||
#: Parking with any of these on the stack could hold a lock the render
|
||||
#: thread takes: logging handler locks, Condition and Event internals, the
|
||||
#: module import locks, and the disk and memory cache locks.
|
||||
_UNSAFE_PATHS = (
|
||||
"logging",
|
||||
"threading.py",
|
||||
"importlib",
|
||||
"cache",
|
||||
)
|
||||
#: Parking inside any of these modules could hold a lock the render thread
|
||||
#: takes: logging handler locks, Condition and Event internals, the module
|
||||
#: import locks, and the disk and memory cache locks. Matched by module name,
|
||||
#: not file path: a path can say "cache" or "logging" for reasons of its own --
|
||||
#: a virtualenv under ~/.cache, or GitHub's /opt/hostedtoolcache, where every
|
||||
#: stdlib frame would otherwise count and the gate would never park anything.
|
||||
_UNSAFE_MODULES = frozenset({
|
||||
"logging", "threading", "importlib", "src.cache_manager", "src.cache",
|
||||
})
|
||||
_UNSAFE_PREFIXES = ("logging.", "importlib.", "_frozen_importlib", "src.cache.")
|
||||
|
||||
|
||||
def _unsafe(frame: Any, base: Any) -> bool:
|
||||
@@ -85,10 +86,9 @@ def _unsafe(frame: Any, base: Any) -> bool:
|
||||
thread's own bootstrap in threading.py) holds nothing.
|
||||
"""
|
||||
while frame is not None and frame is not base:
|
||||
filename = frame.f_code.co_filename
|
||||
for part in _UNSAFE_PATHS:
|
||||
if part in filename:
|
||||
return True
|
||||
name = frame.f_globals.get("__name__") or ""
|
||||
if name in _UNSAFE_MODULES or name.startswith(_UNSAFE_PREFIXES):
|
||||
return True
|
||||
frame = frame.f_back
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user