Skip to content
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

Closed
sahilshekhawat opened this issue Jun 14, 2015 · 13 comments · Fixed by #241
Closed

Clean exit of server #232

sahilshekhawat opened this issue Jun 14, 2015 · 13 comments · Fixed by #241
Assignees
Milestone

Comments

@sahilshekhawat
Copy link
Member

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.

@moorepants
Copy link
Member

If this needs to be fixed for 0.3.0 please at the milestone.

@tarzzz
Copy link
Contributor

tarzzz commented Jun 15, 2015

That seems a good way, @sahilshekhawat you can raise a PR for the same!

@sahilshekhawat
Copy link
Member Author

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.

@moorepants
Copy link
Member

@oliverlee Mentioned that he has a working example of a clean exit. He gave me this link:

oliverlee/bikesim@18ce0f4

But I haven't looked closely yet to find the server exit code.

@oliverlee
Copy link
Contributor

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.

@moorepants
Copy link
Member

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.

@moorepants
Copy link
Member

@sahilshekhawat Does this need to be in the 0.3.0 milestone?

@sahilshekhawat
Copy link
Member Author

We should do this, but I don't know if we have enough time.

@moorepants
Copy link
Member

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?

@sahilshekhawat
Copy link
Member Author

It's not a bug. It's just to hide keyboard interrupt from users on server
exit.

On Tue, Jun 16, 2015, 10:21 Jason K. Moore [email protected] wrote:

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?


Reply to this email directly or view it on GitHub
#232 (comment).

sahilshekhawat added a commit to sahilshekhawat/pydy that referenced this issue Jun 16, 2015
@moorepants
Copy link
Member

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.

@moorepants
Copy link
Member

@sahilshekhawat Have you addressed this in #196?

@sahilshekhawat
Copy link
Member Author

Yes, I have addressed it there.
when we close our server it raises KeyboardInterrupt error and this issue is to show something like "Do you really want to exit [y]/n?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants