From a003c97fba6e1a3456df73ab1d017f1b8e0fcde8 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 18 Sep 2019 10:24:01 +0100 Subject: move q.close() to where it will be called even if deadline is hit --- src/utils/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 60f25f9d..36157204 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -393,7 +393,6 @@ def deadline_process(func: typing.Callable[[], None], seconds: int=10): q.put([True, func()]) except Exception as e: q.put([False, e]) - q.close() p = multiprocessing.Process(target=_wrap, args=(func, q)) p.start() @@ -404,6 +403,8 @@ def deadline_process(func: typing.Callable[[], None], seconds: int=10): except queue.Empty: p.kill() deadlined = True + finally: + q.close() if deadlined: _raise_deadline() -- cgit v1.3.1-10-gc9f91