1

I've tried many different ways of writing a simple HTTP server for Python (using IronPython in a hosted environment) and whenever there is an error (e.g. run-time error) the Python environment just hangs, rather than shutting down and reporting the error.

Update:

There is a comment on an answer to another SO question that suggest that calling "self.server.shutdown()" in a request handler also causes a Python web server to hang in Windows.

So possibly run-time exceptions lead to the same problem.

Community
  • 1
  • 1
cdiggins
  • 17,602
  • 7
  • 105
  • 102

1 Answers1

2

You should probably do something along the lines of:

try:
    httpd.serve_forever()
except RuntimeError:
    httpd.shutdown()
    sys.exit()

btw, this is for python 3 and it assumes that you have the sys module imported.

Lobabob
  • 132
  • 8