Raise the event 'socket_error' when a socket error occurs.

Will be most useful for debugging and responding to failed
connection attempts.
This commit is contained in:
Lance Stout 2011-01-16 13:07:39 -05:00
parent ead3af3135
commit cb85d4a529

View file

@ -292,6 +292,7 @@ class XMLStream(object):
return True
except Socket.error as serr:
error_msg = "Could not connect to %s:%s. Socket Error #%s: %s"
self.event('socket_error', serr)
log.error(error_msg % (self.address[0], self.address[1],
serr.errno, serr.strerror))
time.sleep(1)
@ -327,7 +328,7 @@ class XMLStream(object):
self.filesocket.close()
self.socket.shutdown(Socket.SHUT_RDWR)
except Socket.error as serr:
pass
self.event('socket_error', serr)
finally:
#clear your application state
self.event("disconnected", direct=True)
@ -734,7 +735,8 @@ class XMLStream(object):
except SystemExit:
log.debug("SystemExit in _process")
self.stop.set()
except Socket.error:
except Socket.error as serr:
self.event('socket_error', serr)
log.exception('Socket Error')
except:
if not self.stop.isSet():