aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2019-01-28 19:43:15 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2019-02-15 00:20:26 +0100
commitce44f1302116019e20547fc53447ef8a7a69bea3 (patch)
tree4293049cee9a03d27d08af532a0e068bdd4a1910
parentc8aa7db2e9731cc003718d71a326a12d64e4c438 (diff)
downloadwee-slack-ce44f1302116019e20547fc53447ef8a7a69bea3.tar.gz
Retry rtm.start if it fails
If you're connecting to multiple teams, especially if one of them is large, the call to rtm.start may time out. By retrying it, there's a greater chance that it works (especially since when it tries again, the requests to rtm.start for the other teams have probably finished).
-rw-r--r--wee_slack.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 5c75431..a0fcb3c 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -442,6 +442,13 @@ class EventRouter(object):
elif return_code != -1:
self.reply_buffer.pop(request_metadata.response_id, None)
self.delete_context(data)
+ if request_metadata.request == 'rtm.start':
+ w.prnt('', ('Failed connecting to slack team with token starting with {}, ' +
+ 'retrying. If this persists, try increasing slack_timeout.')
+ .format(request_metadata.token[:15]))
+ dbg('rtm.start failed with return_code {}. stack:\n{}'
+ .format(return_code, ''.join(traceback.format_stack())), level=5)
+ self.receive(request_metadata)
else:
if request_metadata.response_id not in self.reply_buffer:
self.reply_buffer[request_metadata.response_id] = StringIO()