If anyone is interested, then I found out that the finish()
method in the SocketServer.BaseRequestHandler
does nothing to handle closed connections. What I did was following (this also takes care of when the client closes the connection unexpectedly):
def handle(self):
""""
This method will process the incoming request while exit is not set
"""
try:
while not self.exit.is_set():
events = self.epoll.poll(1)
print events
if self.socketEvent in events:
self.handle_request()
if self.QEvent in events:
self.send_response()
if (self.socketEvent[0],25) in events:
self.exit.set()
finally:
self.request.close()
return