From a3204629766daf14eb3f7f29562a45719f9a973b Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Tue, 2 Apr 2019 21:20:30 -0400 Subject: [PATCH] Prevent the timeout callback from running if all tasks completed. Signed-off-by: William D. Jones --- sbysrc/sby_core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index 69d043c..4555e80 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -263,7 +263,8 @@ class SbyJob: async def task_poller(self): if self.opt_timeout is not None: timer_fut = asyncio.ensure_future(self.timekeeper()) - timer_fut.add_done_callback(partial(SbyJob.timeout, self)) + done_cb = partial(SbyJob.timeout, self) + timer_fut.add_done_callback(done_cb) for task in self.tasks_pending: await task.maybe_spawn() @@ -280,6 +281,7 @@ class SbyJob: await task.shutdown_and_notify() if self.opt_timeout is not None: + timer_fut.remove_done_callback(done_cb) timer_fut.cancel() # Required on Windows. I am unsure why, but subprocesses that were