From d42d694e642180a893a70df9c016ca5e6466fc54 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 2 Sep 2019 15:49:55 +0100 Subject: [PATCH] move deadline alarm time check inside try/finally --- src/utils/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/__init__.py b/src/utils/__init__.py index cabfff31..a5a2ac1f 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -364,12 +364,12 @@ def deadline(seconds: int=10): lambda _1, _2: _raise_deadline()) old_seconds, _ = signal.setitimer(signal.ITIMER_REAL, seconds, 0) - if not old_seconds == 0.0 and seconds > old_seconds: - raise ValueError( - "Deadline timeout larger than parent deadline (%s > %s)" % - (seconds, old_seconds)) - try: + if not old_seconds == 0.0 and seconds > old_seconds: + raise ValueError( + "Deadline timeout larger than parent deadline (%s > %s)" % + (seconds, old_seconds)) + yield finally: signal.signal(signal.SIGALRM, old_handler)