WebClient does not retry HTTP requests in any case. Developers may want to have auto-retries for intermittent and/or recoverable errors. We can consider adding a new option (or its underlying function) for auto-retry on the library side.
The primary option should be a retry configuration like urllib3 offers: https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html
retry = Retry(connect=5, read=2, redirect=5, ratelimited=10)
client = WebClient(token="xoxb-", retry=retry)
WebClient can translate the configuration to an error handling function under the hood. The possible function interface can be as below (note: this is a completely pseudo code):
def retry_handler(client, req, error, retry_num) -> Union[SlackResponse, Exception]:
if is_recoverable(error):
return client.retry(req)
else:
return error
client = WebClient(token="xoxb-", retry_handler=retry_handler)
Most developers just need retry config but some may want to take full control of the logic (e.g., implementing exponential backoff retries etc).
AsyncWebClient and WebClient; this means the compatibility with AIOHTTP must be evaluated before deciding the interfaceApp class constructor... what else?
x in each of the [ ])Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
Also a note, the retry should not only retry the command but retry the recreating the connection. Often times Slack responds with a connection reset by peer when you are trying mass calls and to recover you need to reinitialize the client.
Due to my capacity for the next minor release, I've moved this feature from 3.5 to 3.6.
Would love to see this feature!
Most helpful comment
Also a note, the retry should not only retry the command but retry the recreating the connection. Often times Slack responds with a connection reset by peer when you are trying mass calls and to recover you need to reinitialize the client.