Hey Ben,

I haven't used this websocket library, so I don't know much about how it
works, other than a high level guess about it being mostly the same as any
other server with an event loop and connection handling.

You are correct that once you call run_forever() you enter into an event
loop so that the websocket library can poll for connections. When you say
you want to execute an external function... who is initiating this? Is it a
connected client that wants to call an external function? When is this
external function triggered? I wasn't sure if you meant that the external
function was an RPC call for clients, or that you have some other operation
you want to run right after you have set up your websocket server.


On Fri, Dec 18, 2015 at 1:56 AM Ben Hearn <[email protected]> wrote:

> 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:*
> https://gist.github.com/ben-hearn-sb/6f3b283e62e8691119e3
>
> Cheers,
>
> Ben
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/b3d2be9c-5374-4ec2-9924-c2576dc47dc1%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/b3d2be9c-5374-4ec2-9924-c2576dc47dc1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1anUcoYa7Wa34RBjRZ__9m2q7kkEsP%3DBrTMRtjHM-4cg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to