add nested poll check mcp

This commit is contained in:
larssand
2026-07-06 11:03:05 +02:00
parent fc4d83331a
commit 897f593be9
3 changed files with 26 additions and 3 deletions

View File

@@ -38,6 +38,7 @@ def _cycle_timeout(seconds: int):
return
previous_handler = signal.getsignal(signal.SIGALRM)
previous_timer = signal.getitimer(signal.ITIMER_REAL)
started = time.monotonic()
def _raise_timeout(_signum, _frame):
raise TimeoutError(f"status_cycle_timeout_{seconds}s")
@@ -47,7 +48,9 @@ def _cycle_timeout(seconds: int):
try:
yield
finally:
signal.setitimer(signal.ITIMER_REAL, previous_timer[0], previous_timer[1])
elapsed = time.monotonic() - started
remaining = max(0.0, previous_timer[0] - elapsed) if previous_timer[0] else 0.0
signal.setitimer(signal.ITIMER_REAL, remaining, previous_timer[1])
signal.signal(signal.SIGALRM, previous_handler)