Jun-21-2020, 10:59 PM
(This post was last modified: Jun-21-2020, 11:03 PM by Gribouillis.)
A solution that I have used in the pass is to create a
socketserver.ThreadingTCPServer
instance and launch a thread that runs the server's serve_forever()
method. One needs to create a subclass of socketserver.StreamRequestHandler
with a handle()
method that does something useful.Once the server is launched, the main thread can do anything it wants and the socketserver will handle connections and requests in other threads as they arrive.