Hi,

I have a small application with an embedded wsgi server
(wsgiref.simple_server).

I'd like to quit the server as nicely as possible when I quit the
application.


How to do this best?


What I do so far: (simplified, but you should get the idea)


from wsgiref.simple_server import make_server

# create an httpd server
httpd = make_server('', 8080, my_application)


def run(): # function handling requests
   global running
   running=True
   while self.running:
        self.httpd.handle_request()

def stop():
    global running
    running=False

# now call run from a thread

# before shutting down the application call the function stop()


Problem:
Calling stop() will set the running flag to False, but
the code is still blocking in self.httpd.handle_request()

Of course I could send an http request to myself, but then the problem
would be what happens if somebody else had sent a request before me.


Just curious how you handle such situations

Thanks in advance for any suggestions








-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to