This commit makes the fix more robust. Seems to have solved the issue once and for all.

This commit is contained in:
Joe Landers 2024-09-13 16:33:00 -07:00
parent b27a041c51
commit 17eef3c450
1 changed files with 7 additions and 1 deletions

View File

@ -46,7 +46,13 @@ def message_handler():
logger.info( logger.info(
f"Sending message to connection_id: {message['connection_id']}. Connection ID: {socket_client_id}" f"Sending message to connection_id: {message['connection_id']}. Connection ID: {socket_client_id}"
) )
asyncio.run(websocket_manager.send_message(message, connection)) coro = websocket_manager.send_message(message, connection)
try:
loop = asyncio.get_running_loop()
asyncio.run_coroutine_threadsafe(coro, loop)
except RuntimeError:
asyncio.run(coro)
else: else:
logger.info( logger.info(
f"Skipping message for connection_id: {message['connection_id']}. Connection ID: {socket_client_id}" f"Skipping message for connection_id: {message['connection_id']}. Connection ID: {socket_client_id}"