Skip to content

Commit 6ed2b13

Browse files
committed
Run message processing in background tasks
1 parent 2ab9808 commit 6ed2b13

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

meeseeks/core.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ def _init_apps(self) -> list[_T]:
137137

138138
return app_instances
139139

140-
async def loop(self) -> None:
141-
"""Method is intended for calling in endless loop to process Rocket.Chat callbacks. """
140+
async def message_handler(self, message: str) -> None:
141+
"""Serializes message context and run processing for each app. """
142142

143-
raw_context: WebSocketClientProtocol = json.loads(await self._websocket.recv())
143+
raw_context: WebSocketClientProtocol = json.loads(message)
144144
if raw_context.get('msg') == 'ping':
145145
await self._rtapi.pong()
146146
return None
@@ -193,9 +193,9 @@ async def run(self) -> None:
193193
self.check_app_name(app)
194194
await app.setup()
195195

196-
while True:
196+
async for message in websocket:
197197
try:
198-
await self.loop()
198+
asyncio.create_task(self.message_handler(message))
199199
except ClientResponseError as exc:
200200
LOGGER.error(exc)
201201
except ConnectionClosedOK:

0 commit comments

Comments
 (0)