Speed up Scheduler.stop()
@@ -331,7 +331,10 @@ class Scheduler(object):
pass # Process has terminated
if self._task_processes:
- await asyncio.sleep(self._STOP_WAIT_SECONDS)
+ for _ in range(self._STOP_WAIT_SECONDS):
+ if not self._task_processes:
+ break
+ await asyncio.sleep(1)
if self._task_processes:
raise TimeoutError()
