Hello all,
I have been setting up some communication between applications using websockets in python. The module is websocket-client.
The comms is great, the messages are sent and received which is what I need I have hit a snag though. I have a function inside my script that needs to be called from Maya whenever we need it to.
When the websocket is set up I call run_forever to keep the socket open for future comms. The problem is I cannot jump out of the run_forever loop so that the executeExternal function can be called.
I have read up on Queues but am stumped with how to use properly or if I should in this case?
The idea is that I will eventually call the main function for the websocket inside a thread from Maya like so:
# Inside user setup or wherever in the code base
import ws
import threading
ws = threading.Thread(target=ws.main)
ws.start()
# Call execute external function later from wherever in the code base
Code is below:
Cheers,
Ben