mirror of
https://git.wownero.com/wownero/tippero.git
synced 2024-08-15 00:33:14 +00:00
Detect a few "kicked from IRC" conditions, reconnect after a pause
This commit is contained in:
parent
5224a0ef58
commit
8e0d6957d3
1 changed files with 20 additions and 2 deletions
22
tipbot.py
22
tipbot.py
|
@ -706,6 +706,9 @@ def getline(s):
|
|||
newdata = None
|
||||
except Exception,e:
|
||||
log_error('getline: Exception: %s' % str(e))
|
||||
# Broken pipe when we get kicked for spam
|
||||
if str(e).find("Broken pipe") != -1:
|
||||
raise
|
||||
newdata = None
|
||||
if newdata == None:
|
||||
return None
|
||||
|
@ -727,14 +730,22 @@ InitScanBlockHeight()
|
|||
|
||||
while True:
|
||||
action = None
|
||||
data = getline(irc)
|
||||
try:
|
||||
data = getline(irc)
|
||||
except Exception,e:
|
||||
log_warn('Exception fron getline, we were probably disconnected, reconnecting in 5 seconds')
|
||||
time.sleep(5)
|
||||
last_ping_time = time.time()
|
||||
connect_to_irc(irc_network,irc_port)
|
||||
continue
|
||||
|
||||
# All that must be done even when nothing from IRC - data may be None here
|
||||
UpdateCoin()
|
||||
|
||||
if data == None:
|
||||
if time.time() - last_ping_time > irc_timeout_seconds:
|
||||
log_warn('%s seconds without PING, reconnecting' % irc_timeout_seconds)
|
||||
log_warn('%s seconds without PING, reconnecting in 5 seconds' % irc_timeout_seconds)
|
||||
time.sleep(5)
|
||||
last_ping_time = time.time()
|
||||
connect_to_irc(irc_network,irc_port)
|
||||
continue
|
||||
|
@ -756,6 +767,13 @@ while True:
|
|||
irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
|
||||
continue
|
||||
|
||||
if data.find('ERROR :Closing Link:') == 0:
|
||||
log_warn('We were kicked from IRC, reconnecting in 5 seconds')
|
||||
time.sleep(5)
|
||||
last_ping_time = time.time()
|
||||
connect_to_irc(irc_network,irc_port)
|
||||
continue
|
||||
|
||||
#--------------------------- Action check --------------------------------#
|
||||
if data.find(':') == -1:
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue