diff --git a/bin/linspector b/bin/linspector index d476d9b..cba15c1 100755 --- a/bin/linspector +++ b/bin/linspector @@ -158,13 +158,16 @@ def main(): logger.debug("shutting down scheduler") - shutdown_wait = True if "shutdown_wait" in core: shutdown_wait = core["shutdown_wait"] scheduler.shutdown(wait=shutdown_wait) logging.shutdown() + if shutdown_wait: + TaskExecutor.Instance().stop() + else: + TaskExecutor.Instance().stop_immediately() if __name__ == "__main__": diff --git a/linspector/tasks/task.py b/linspector/tasks/task.py index de22ed1..897b22f 100644 --- a/linspector/tasks/task.py +++ b/linspector/tasks/task.py @@ -76,13 +76,12 @@ class TaskExecutor(object): self.event = Event() self.taskInfos = [] task_thread = Thread(target=self._run_worker_thread) - task_thread.setDaemon(True) self._instantEnd = False self._running = True task_thread.start() def _run_worker_thread(self): - while self.is_running() or not self.instand_end(): + while self.is_running() or not self.is_instant_end(): if len(self.taskInfos) == 0: self.event.clear() self.event.wait() @@ -105,11 +104,13 @@ class TaskExecutor(object): def stop(self): self._running = False + self.event.set() def stop_immediately(self): - self.stop() + self._running = False self._instantEnd = True + self.event.set() def schedule_task(self, msg, task): self.taskInfos.append((msg, task)) - self.event.set() \ No newline at end of file + self.event.set()