Skip to content

Commit

Permalink
fix: scheduler shutdown (eosphoros-ai#1237)
Browse files Browse the repository at this point in the history
  • Loading branch information
polBachelin authored and Hopshine committed Sep 10, 2024
1 parent 903db33 commit d125466
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dbgpt/app/initialization/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ def __init__(
self.system_app = system_app
self._scheduler_interval_ms = scheduler_interval_ms
self._scheduler_delay_ms = scheduler_delay_ms
self._stop_event = threading.Event()

def init_app(self, system_app: SystemApp):
self.system_app = system_app

def after_start(self):
thread = threading.Thread(target=self._scheduler)
thread.start()
self._stop_event.clear()

def before_stop(self):
self._stop_event.set()

def _scheduler(self):
time.sleep(self._scheduler_delay_ms / 1000)
while True:
while not self._stop_event.is_set():
try:
schedule.run_pending()
except Exception as e:
Expand Down

0 comments on commit d125466

Please sign in to comment.