Skip to content

Commit

Permalink
Merge pull request #86 from PlaidCloud/add-logging-tools-to-rpcretry
Browse files Browse the repository at this point in the history
Add logging tools to rpcretry
  • Loading branch information
kkapper authored Apr 22, 2024
2 parents 6af7a18 + 6f40e63 commit c8d7194
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions plaidcloud/rpc/connection/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,15 @@ def on_request_complete(request_future):
class RPCRetry(Retry):
def __init__(self, *args, check_allow_transmit=None, **kwargs):
"""
Args:
check_allow_transmit (callable, optional): Method to call to check if retries are still to be made
This can be used to prevent retry of RPC methods once a workflow has been cancelled and the RPC fails
"""
if version.parse(urllib3.__version__) >= version.parse("1.26.0"):
kwargs.update(dict(
allowed_methods=['POST'],
status_forcelist=[500, 502, 504],
backoff_factor=0.1,
))
else:
kwargs.update(dict(
method_whitelist=['POST'],
status_forcelist=[500, 502, 504],
backoff_factor=0.1,
))
kwargs.update(dict(
allowed_methods=['POST'],
status_forcelist=[500, 502, 504],
backoff_factor=0.1,
))
if 'connect' not in kwargs:
kwargs['connect'] = 5
super(RPCRetry, self).__init__(*args, **kwargs)
Expand All @@ -168,6 +160,7 @@ def allow_transmit(self):
return True

def increment(self, *args, **kwargs):
print(f'Hit Retry, Request History Looks Like: {self.history}')
if not self.allow_transmit:
raise Exception('No more retries, RPC method has been cancelled')
return super(RPCRetry, self).increment(*args, **kwargs)
Expand Down

0 comments on commit c8d7194

Please sign in to comment.