try to reconnect when socket error

is raised during data receiving
This commit is contained in:
Dimitur Kirov 2006-02-11 21:30:04 +00:00
parent 79d39ac119
commit 19ee5917bf
1 changed files with 10 additions and 3 deletions

View File

@ -203,16 +203,23 @@ class NonBlockingTcp(PlugIn, IdleObject):
except Exception, e:
if len(e.args) > 0 and isinstance(e.args[0], int):
errnum = e[0]
print 'errnum:',errnum, e
# "received" will be empty anyhow
if not received and errnum != 2:
if errnum != 8: # EOF occurred in violation of protocol
if errnum == socket.SSL_ERROR_WANT_READ:
pass
elif errnum in [errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN]:
self.disconnect()
if self.on_connect_failure:
self.on_connect_failure()
elif not received :
if errnum != socket.SSL_ERROR_EOF: # 8 EOF occurred in violation of protocol
self.DEBUG('Socket error while receiving data', 'error')
if self.state >= 0:
self.disconnect()
return False
if self.state < 0:
return
# we have received some bites, stop the timeout!
self.renew_send_timeout()
if self.on_receive: