diff --git a/graphify/hooks.py b/graphify/hooks.py index 455c70a4..afb45588 100644 --- a/graphify/hooks.py +++ b/graphify/hooks.py @@ -171,7 +171,7 @@ try: signal.alarm(_timeout) else: def _bail(): - print(f'[graphify hook] graphify rebuild exceeded {_timeout}s', flush=True) + print(f'[graphify] graphify rebuild exceeded {_timeout}s', flush=True) os._exit(1) _watchdog = threading.Timer(_timeout, _bail) _watchdog.daemon = True diff --git a/tests/test_hooks.py b/tests/test_hooks.py index f21b7e31..3ea7ed2b 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -348,6 +348,11 @@ def test_rebuild_bodies_arm_a_timeout_without_sigalrm(name, body): dumped = "".join(ast.dump(stmt) for stmt in fallbacks[0]) assert "attr='Timer'" in dumped, f"{name} fallback does not arm a threading.Timer (#2148)" assert "attr='_exit'" in dumped, f"{name} fallback does not kill the stuck rebuild (#2148)" + # The fallback logs the timeout itself, because os._exit skips the except + # handler that reports it on the SIGALRM path. Its prefix has to match the + # rest of the body, or the same event reads differently per platform. + prefixes = set(re.findall(r"print\(f'\[([a-z ]+)\]", body)) + assert len(prefixes) == 1, f"{name} mixes log prefixes {sorted(prefixes)} (#2148)" def test_detached_launch_targets_graphify_python():