diff --git a/src/bot/application.py b/src/bot/application.py index c557eace35..726cdbdbf0 100644 --- a/src/bot/application.py +++ b/src/bot/application.py @@ -47,6 +47,7 @@ class Application(DiscordBotApplicationABC): self._api.start() if self._feature_flags.get_flag(FeatureFlagsEnum.api_only): + self._api.join() return self._logger.trace(__name__, f'Try to start {DiscordBotService.__name__}') diff --git a/src/bot_api/api_thread.py b/src/bot_api/api_thread.py index b6a34bde4d..f3ecf6cc76 100644 --- a/src/bot_api/api_thread.py +++ b/src/bot_api/api_thread.py @@ -14,7 +14,7 @@ class ApiThread(threading.Thread): api: Api, feature_flags: FeatureFlagsSettings ): - threading.Thread.__init__(self, daemon=not feature_flags.get_flag(FeatureFlagsEnum.api_only)) + threading.Thread.__init__(self, daemon=True) self._logger = logger self._api = api diff --git a/src/bot_api/bot-api.json b/src/bot_api/bot-api.json index b31234fd9b..09e4129308 100644 --- a/src/bot_api/bot-api.json +++ b/src/bot_api/bot-api.json @@ -17,7 +17,7 @@ "LicenseDescription": "", "Dependencies": [ "cpl-core==2022.10.0.post6", - "Flask==2.2.2", + "Flask[async]==2.2.2", "Flask-Classful==0.14.2" ], "DevDependencies": [ diff --git a/src/bot_api/controller/api_controller.py b/src/bot_api/controller/api_controller.py index e17103e6dd..1b7ae669d2 100644 --- a/src/bot_api/controller/api_controller.py +++ b/src/bot_api/controller/api_controller.py @@ -33,13 +33,13 @@ class ApiController: self._mailer = mailer @Route.route('/api/api-version') - def api_version(self): + async def api_version(self): import bot_api version = bot_api.version_info return VersionDTO(version.major, version.minor, version.micro).to_dict() @Route.route('/api/settings') - def settings(self): + async def settings(self): # TODO: Authentication import bot_api version = bot_api.version_info @@ -60,7 +60,7 @@ class ApiController: ).to_dict() @Route.route('/api/send-test-mail/') - def send_test_mail(self, email: str): + async def send_test_mail(self, email: str): # TODO: Authentication mail = EMail() mail.add_header('Mime-Version: 1.0')