Thanks! I'm not sure how to do that, though. I'm aiming for something like this (omitting the queue-producer code):
def handle(request): # gevent.core.http_connection
### Wait for another greenlet to put an item on a queue
request.send_reply(200, 'OK', item_from_queue)
### launch separate greenlet to put items on queue
# set up web server
server = HTTPServer(('0.0.0.0', 10545), handle)
print "Serving on port 10545."
I was hoping HTTPServer would allow for a connection loss handler, but it doesn't seem to.
I'm not sure how to implement your suggestion for two reasons:
- How can I access the socket from the gevent.core.http_connection object? I can't find anything in the docs.
- If I can get to the socket, does this mean I have to poll the socket periodically for EOF? I'd rather avoid polling.