How to programmatically exit from wsgi's serve_forever() loop

python at bdurham.com python at bdurham.com
Tue Dec 28 14:08:45 EST 2010


Hi Ian,

You are correct - I missed the following 2 nuances:

# need to set poll_interval in order to recognize shutdown request
httpd.serve_forever(poll_interval=0.5)

# shutdown request must be initiated from ANOTHER thread or will block
import threading
threading.Thread(target=httpd.shutdown).start()

Thank you for your help - really appreciated!

Malcolm



More information about the Python-list mailing list