-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Dynamically loading dbgpts (#1211)
- Loading branch information
Showing
15 changed files
with
504 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import logging | ||
import threading | ||
import time | ||
|
||
import schedule | ||
|
||
from dbgpt.component import BaseComponent, SystemApp | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class DefaultScheduler(BaseComponent): | ||
"""The default scheduler""" | ||
|
||
name = "dbgpt_default_scheduler" | ||
|
||
def __init__( | ||
self, | ||
system_app: SystemApp, | ||
scheduler_delay_ms: int = 5000, | ||
scheduler_interval_ms: int = 1000, | ||
): | ||
super().__init__(system_app) | ||
self.system_app = system_app | ||
self._scheduler_interval_ms = scheduler_interval_ms | ||
self._scheduler_delay_ms = scheduler_delay_ms | ||
|
||
def init_app(self, system_app: SystemApp): | ||
self.system_app = system_app | ||
|
||
def after_start(self): | ||
thread = threading.Thread(target=self._scheduler) | ||
thread.start() | ||
|
||
def _scheduler(self): | ||
time.sleep(self._scheduler_delay_ms / 1000) | ||
while True: | ||
try: | ||
schedule.run_pending() | ||
except Exception as e: | ||
logger.debug(f"Scheduler error: {e}") | ||
finally: | ||
time.sleep(self._scheduler_interval_ms / 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.