Skip to content

Commit

Permalink
Retry failed hangouts->slack sends (eg if slack API is flaking out)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Rorex committed Jun 20, 2016
1 parent b512796 commit e06bbcc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions slackups/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _on_hangups_connect(self):


@asyncio.coroutine
def _on_hangups_event(self, conv_event):
def _on_hangups_event(self, conv_event, retry=0):
"""Called when a hangups conversation event occurs."""
try:
logger.info("Hangups Event: "+conv_event.__class__.__name__)
Expand All @@ -83,7 +83,13 @@ def _on_hangups_event(self, conv_event):
logger.warning("Unknown membership change type: "+str(conv_event.type))

except:
logger.warning("Error handling hangouts event!")
logger.exception("Error handling hangouts event!")
if retry < 5:
yield from asyncio.sleep(retry+0.1)
logger.info("RETRYING")
yield from self._on_hangups_event(conv_event, retry+1)
else:
logger.critical("##########GAVE UP RETRYING############")


# Client Callbacks
Expand Down

0 comments on commit e06bbcc

Please sign in to comment.