-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How (where) to close the server? #49
Comments
I had the same issue, I solved this by adding in server.py at the top:
Then at the bottom of _handle_request add:
You can then just add to your main.py:
Or whatever path you want to shutdown the server once it finishes. Then just visit /shutdown, and it should close the web server after it displays the page content. |
I manage to close the server with the above method but with that code I did not like to modify "server.py" so instead I put in my main loop
It's working and I can put code after server.run The message "SERVER CLOSED" appears when I stop my progran. |
I'm running a program that gathers every 15mn. During the time.sleep, the Phew server must be running to display the collected data. Thus the server must stop automatically after 14mn. I did it that way :
The code ts not very clean because the "Task exception wasn't retrieved" but it works. But I don't understand what is the parameter to use. I need help to solve that problem. Thanks in advance |
I want to retrieve some information through a web server and then close it, but I don't really understand how am I supposed to do that.
server.run()
is blocking, so no code past this call ever executes. The only place I see where I could callserver.close()
is the request handler function, but that seems ugly because then it can't return a responseThe text was updated successfully, but these errors were encountered: