Skip to content

Commit

Permalink
MarketMonitor: automatically reconnect if feed is quiet for 5 min.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Folkinshteyn committed May 12, 2015
1 parent dbb0cfe commit c4d54a0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion MarketMonitor/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, irc):
# Example: {("mtgox", "USD"): [(volume, price, timestamp),(volume, price, timestamp)], ("th", "USD"): [(volume, price, timestamp)]}

self.raw = []
self.nextsend = 0 # Timestamp for when we can send next. Handling this manually allows better collapsing.
self.nextsend = time.time() # Timestamp for when we can send next. Handling this manually allows better collapsing.

def __call__(self, irc, msg):
self.__parent.__call__(irc, msg)
Expand Down Expand Up @@ -111,6 +111,8 @@ def _monitor(self, irc):
for chan in self.registryValue('channels'):
irc.queueMsg(ircmsgs.privmsg(chan, output))
self.nextsend = time.time()+(conf.supybot.protocols.irc.throttleTime() * len(outputs))
if time.time() - self.nextsend > 300: # 5 minutes no data
self._reconnect() # must mean feed is quietly dead, as sometimes happens.
self.marketdata = {}
self.raw = []
except Exception, e:
Expand Down

0 comments on commit c4d54a0

Please sign in to comment.