-
Notifications
You must be signed in to change notification settings - Fork 775
Description
Hi,
I've got a bit of a difficult use-case. I'm working on a multithreaded program that needs to utilize a websocket connection to initiate a refresh of settings (stored in module-wide variables). However, I also need to use the websocket connection to request specific information from within other threads. I thought I could solve this by storing the WebSocketApp connection in the global variables, and then trigger/receive the messages with settings.ws.send() and settings.ws.sock.recv(). However, this works exactly once... Any subsequent attempts result in the thread that called the .recv() function to wait endlessly, while the response is handled in the onMessage function.
My best guess is that the settings.ws.sock.recv() responds once because the dispatcher is not yet active, but on subsequent calls directs the responses to onMessage().
So, to sum it up, here are the questions:
- Is it possible to manually receive a response outside of on_message when running a
websocket.WebSocketApp? - Would this approach be possible if I wrote my own class or stored the actual create_connection in a variable? I don't know enough about websockets to judge whether what I'm doing is actually possible/intended with a websocket connection.
Thanks in advance!