Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scheduler shutdown #1237

Merged
merged 4 commits into from
Mar 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading