Skip to content

Running a Websocket client in a different thread or process alongside other tasks/code executing in the program #1625

Closed Answered by oberstet
n-srinidhi asked this question in Q&A
Discussion options

You must be logged in to vote

Not using threads keeps my other code from executing and only the web socket part is active.

You should aim for having all of your "other code" itself non-blocking and using Twisted or asyncio (eg StartEngineServer would return a Deferred or Future). This is the "right" way.

If this is not the case, e.g. your StartEngineServer is using plain Python socket API, which is blocking, things will get complicated.

One way in this case is to run StartEngineServer on a background thread and interact from that with Twisted/asyncio/WebSocket/Autobahn running on the main thread.

That interaction from the background thread with the main thread - which is running the Twisted/asyncio reactor/event loo…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@n-srinidhi
Comment options

Comment options

You must be logged in to vote
1 reply
@n-srinidhi
Comment options

Comment options

You must be logged in to vote
1 reply
@n-srinidhi
Comment options

Answer selected by n-srinidhi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants