From 583218b2150075b9ad83cfd2e25851dfa04c4f72 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 2 Apr 2023 14:41:05 +0200 Subject: [PATCH 1/2] Set async mode in web api #290 --- kdb-bot/src/bot_api/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kdb-bot/src/bot_api/api.py b/kdb-bot/src/bot_api/api.py index 023fd54b..3bef843c 100644 --- a/kdb-bot/src/bot_api/api.py +++ b/kdb-bot/src/bot_api/api.py @@ -53,7 +53,9 @@ class Api(Flask): self.register_error_handler(exc_class, self.handle_exception) # websockets - self._socketio = SocketIO(self, cors_allowed_origins="*", path="/api/socket.io") + # Added async_mode see link below + # https://stackoverflow.com/questions/39370848/flask-socket-io-sometimes-client-calls-freeze-the-server + self._socketio = SocketIO(self, cors_allowed_origins="*", path="/api/socket.io", async_mode="eventlet") self._socketio.on_event("connect", self.on_connect) self._socketio.on_event("disconnect", self.on_disconnect) -- 2.45.2 From c1e8274f46dd8a2607f18edec3286ea6300b070f Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 2 Apr 2023 18:30:46 +0200 Subject: [PATCH 2/2] Set async mode in web api #290 --- kdb-bot/src/bot_api/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kdb-bot/src/bot_api/api.py b/kdb-bot/src/bot_api/api.py index 3bef843c..01211837 100644 --- a/kdb-bot/src/bot_api/api.py +++ b/kdb-bot/src/bot_api/api.py @@ -55,7 +55,8 @@ class Api(Flask): # websockets # Added async_mode see link below # https://stackoverflow.com/questions/39370848/flask-socket-io-sometimes-client-calls-freeze-the-server - self._socketio = SocketIO(self, cors_allowed_origins="*", path="/api/socket.io", async_mode="eventlet") + # https://github.com/miguelgrinberg/Flask-SocketIO/discussions/1849 + self._socketio = SocketIO(self, cors_allowed_origins="*", path="/api/socket.io", async_mode="threading") self._socketio.on_event("connect", self.on_connect) self._socketio.on_event("disconnect", self.on_disconnect) -- 2.45.2