-
Notifications
You must be signed in to change notification settings - Fork 114
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
Clean exit of server #232
Comments
If this needs to be fixed for 0.3.0 please at the milestone. |
That seems a good way, @sahilshekhawat you can raise a PR for the same! |
But it still raises KeyBoardInterrupt when a request is being processed. To fix this we need to create our custom subclasses of BaseHTTPServer and SimpleHTTPRequestHandler. I will try to fix it as soon as other more important bugs can be fixed for the release. |
@oliverlee Mentioned that he has a working example of a clean exit. He gave me this link: But I haven't looked closely yet to find the server exit code. |
You can run the server in a separate thread from the main thread. In the main thread, you can catch a KeyboardException and signal the server thread. The signal thread periodically checks if it should terminate, and if so, performs your shutdown/cleanup actions. At this point, the server thread function finishes and the server thread terminates. You can signal a thread easily with threading.Event(). Also please try to use the print function so that it is easier to maintain compatibility with Python 3. |
The new Travis tests will ensure this for the future. |
@sahilshekhawat Does this need to be in the 0.3.0 milestone? |
We should do this, but I don't know if we have enough time. |
If it is critical to have a functioning app, we can ensure that it gets in. I don't really understand the bug yet? I haven't experienced it. How do you reproduce it? |
It's not a bug. It's just to hide keyboard interrupt from users on server On Tue, Jun 16, 2015, 10:21 Jason K. Moore [email protected] wrote:
|
Can you explain in steps how to reproduce this behavior? I still don't understand what is going on. Also can you please give your opinion on whether this is critical for the 0.3.0 release? If it is not a bug, I'm guessing it is not critical. |
@sahilshekhawat Have you addressed this in #196? |
Yes, I have addressed it there. |
I have few samples of how we can do this: HERE and HERE
Both of them fails sometimes because handle_request processes thread in another thread and thus I cannot catch the keyboard interrupt. This fails only when a request is being processing.
The text was updated successfully, but these errors were encountered: