Forum Archive

Stopping SimpleHTTPServer

emkay

I am using SimpleHTTPServer in an Editorial workflow. This works well, except the stop button and the spinning button do not kill the workflow.

The background timeout will kill the workflow, but I am unable to do it manually.

Can anyone help?

Thanks

Martin

filippocld223

what about stopping the workflow with a raw input?

exit=raw_input("Do you want to exit?")
if exit=="yes":
    sys.exit()
emkay

Thanks for the idea, but it am running the example at the end http://omz-software.com/editorial/docs/library/simplehttpserver.html

There isn't a place to put the raw_input.

I'll keep hunting for ways to stop it (it stops under pythonista, so I'm sure there is a way).

Martin

ccc

Two approaches to consider:

  1. avoid serve_ forever() http://docs.python.org/2/library/basehttpserver.html#more-examples
  2. threading http://stackoverflow.com/questions/11493985/python-basehttpserver-how-to-get-it-to-stop