mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +00:00
Make socket_error run as a direct event to ensure that it is handled.
Socket errors that occur before stream processing begins could not be handled as the event loop would not be running yet. Resolves issue #142
This commit is contained in:
parent
8f25acd0f3
commit
3ab7c8bcc3
1 changed files with 6 additions and 6 deletions
|
@ -454,7 +454,7 @@ class XMLStream(object):
|
||||||
return True
|
return True
|
||||||
except Socket.error as serr:
|
except Socket.error as serr:
|
||||||
error_msg = "Could not connect to %s:%s. Socket Error #%s: %s"
|
error_msg = "Could not connect to %s:%s. Socket Error #%s: %s"
|
||||||
self.event('socket_error', serr)
|
self.event('socket_error', serr, direct=True)
|
||||||
log.error(error_msg, self.address[0], self.address[1],
|
log.error(error_msg, self.address[0], self.address[1],
|
||||||
serr.errno, serr.strerror)
|
serr.errno, serr.strerror)
|
||||||
self.reconnect_delay = delay
|
self.reconnect_delay = delay
|
||||||
|
@ -507,7 +507,7 @@ class XMLStream(object):
|
||||||
return True
|
return True
|
||||||
except Socket.error as serr:
|
except Socket.error as serr:
|
||||||
error_msg = "Could not connect to %s:%s. Socket Error #%s: %s"
|
error_msg = "Could not connect to %s:%s. Socket Error #%s: %s"
|
||||||
self.event('socket_error', serr)
|
self.event('socket_error', serr, direct=True)
|
||||||
log.error(error_msg, self.address[0], self.address[1],
|
log.error(error_msg, self.address[0], self.address[1],
|
||||||
serr.errno, serr.strerror)
|
serr.errno, serr.strerror)
|
||||||
return False
|
return False
|
||||||
|
@ -578,7 +578,7 @@ class XMLStream(object):
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
self.filesocket.close()
|
self.filesocket.close()
|
||||||
except Socket.error as serr:
|
except Socket.error as serr:
|
||||||
self.event('socket_error', serr)
|
self.event('socket_error', serr, direct=True)
|
||||||
finally:
|
finally:
|
||||||
#clear your application state
|
#clear your application state
|
||||||
self.event("disconnected", direct=True)
|
self.event("disconnected", direct=True)
|
||||||
|
@ -1092,7 +1092,7 @@ class XMLStream(object):
|
||||||
if count > 1:
|
if count > 1:
|
||||||
log.debug('SENT: %d chunks', count)
|
log.debug('SENT: %d chunks', count)
|
||||||
except Socket.error as serr:
|
except Socket.error as serr:
|
||||||
self.event('socket_error', serr)
|
self.event('socket_error', serr, direct=True)
|
||||||
log.warning("Failed to send %s", data)
|
log.warning("Failed to send %s", data)
|
||||||
if reconnect is None:
|
if reconnect is None:
|
||||||
reconnect = self.auto_reconnect
|
reconnect = self.auto_reconnect
|
||||||
|
@ -1193,7 +1193,7 @@ class XMLStream(object):
|
||||||
shutdown = True
|
shutdown = True
|
||||||
self.exception(e)
|
self.exception(e)
|
||||||
except Socket.error as serr:
|
except Socket.error as serr:
|
||||||
self.event('socket_error', serr)
|
self.event('socket_error', serr, direct=True)
|
||||||
log.exception('Socket Error')
|
log.exception('Socket Error')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if not self.stop.is_set():
|
if not self.stop.is_set():
|
||||||
|
@ -1445,7 +1445,7 @@ class XMLStream(object):
|
||||||
log.debug('SENT: %d chunks', count)
|
log.debug('SENT: %d chunks', count)
|
||||||
self.send_queue.task_done()
|
self.send_queue.task_done()
|
||||||
except Socket.error as serr:
|
except Socket.error as serr:
|
||||||
self.event('socket_error', serr)
|
self.event('socket_error', serr, direct=True)
|
||||||
log.warning("Failed to send %s", data)
|
log.warning("Failed to send %s", data)
|
||||||
self.__failed_send_stanza = data
|
self.__failed_send_stanza = data
|
||||||
self.disconnect(self.auto_reconnect)
|
self.disconnect(self.auto_reconnect)
|
||||||
|
|
Loading…
Reference in a new issue