I’m using the SocketServer module in python to implement a simple embedded web server in my application. At the moment I’m calling the serve_forver method within a dedicated thread in order to continue the execution of my application.
I was wondering if there is there a more pythonic way to start my SocketServer and retun the execution to my application.
That is a very pythonic way:
I don’t see how that could be unclear or overly verbose. If you want the program to exit once your main thread finishes, add
daemon=Trueto theThreadcall.An alternative is calling
handle_requestin a loop yourself, but that doesn’t seem applicable to your case of a web-server.