move q.close() to where it will be called even if deadline is hit

This commit is contained in:
jesopo 2019-09-18 10:24:01 +01:00
parent dce6eee8c9
commit a003c97fba

View file

@ -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()