Make web.py applications stoppable in stand-alone mode #122

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
@Irfy

Irfy commented Dec 16, 2011

I added an app.stop() method to be able to stop the stand-alone server programmatically in dev-mode, for whatever reason.

My reason is that I'm serving http requests in an embedded system without a 'proper' web server front-end, as part of a larger multithreaded python application, which needs to support stopping and restarting for management purposes.

Make web.py applications stoppable in stand-alone mode
web.py applications typically run in WSGI mode, but when used in embedded
environments, it may be more useful to run the application in stand-alone
server mode (a.k.a. 'app.run()').

Also, running the application via 'app.run()' in a different thread kills
the out-of-the-box behavior of stopping the application with Ctrl-C.

This patch adds the 'stop(self)' method to the application class, so that
applications running stand-alone can be stopped easily with 'app.stop()'.

Credits: llc at stackoverflow: http://stackoverflow.com/questions/5389111

Related to: #100
@anandology

This comment has been minimized.

Show comment Hide comment
@anandology

anandology May 22, 2012

Owner

raising sys.exit() will stop the app now.

I don't think we need to add app.stop().

Owner

anandology commented May 22, 2012

raising sys.exit() will stop the app now.

I don't think we need to add app.stop().

@anandology anandology closed this May 22, 2012

@Irfy

This comment has been minimized.

Show comment Hide comment
@Irfy

Irfy May 23, 2012

sys.exit() doesn't handle the case where the web application is embedded in another application that needs to restart just the web server, whereas an explicit app.stop() would.

Irfy commented May 23, 2012

sys.exit() doesn't handle the case where the web application is embedded in another application that needs to restart just the web server, whereas an explicit app.stop() would.

anandology added a commit that referenced this pull request May 24, 2012

@anandology

This comment has been minimized.

Show comment Hide comment
@anandology

anandology May 24, 2012

Owner

app.stop() is added now.

Owner

anandology commented May 24, 2012

app.stop() is added now.

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