Sublime Forum

Socket server inside sublime text

#1

What’s the best way of running a socket server in sublime’s plugin system?

I’ve looked at async io but looks like it’s only in a newer version of python
I’ve looked at set_timeout_async, but I would need a way to stop the server too
I’ve looked at asynchat but for some reason, I can’t get it to not block
I’m looking at threading but not sure how to do signaling yet (to send the stop server)

What’s the most idiomatic way of doing this?
Are there any other plugins with socket servers?

0 Likes

#2

multiprocessing looks interesting seems easier to share state

0 Likes

#3

You may use the socket library in ST inside its own thread. Other than that, the usual multithread patterns apply, like setting an event from a different thread and checking that from within the socket thread to signal it to stop, for example.

0 Likes