From 9da9c36e24427c3326f1b6dd504dc149fde5619d Mon Sep 17 00:00:00 2001 From: Harshil Goel Date: Sun, 8 Aug 2021 00:50:45 +0530 Subject: [PATCH] Added a retry logic to sending events --- .../Libraries/Shared/plugin/managers/action.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Trakttv.bundle/Contents/Libraries/Shared/plugin/managers/action.py b/Trakttv.bundle/Contents/Libraries/Shared/plugin/managers/action.py index 05b20874b..96a2cc594 100644 --- a/Trakttv.bundle/Contents/Libraries/Shared/plugin/managers/action.py +++ b/Trakttv.bundle/Contents/Libraries/Shared/plugin/managers/action.py @@ -155,11 +155,15 @@ def process(cls, action): log.debug('Sending action %r (account: %r, interface: %r, method: %r)', action.event, action.account, interface, method) - try: - result = cls.send(action, Trakt[interface][method], request) - except Exception as ex: - log.error('Unable to send action %r: %r', action.event, ex, exc_info=True) - return None + result = None + for retry_count in range(5): + try: + if retry_count > 0: + log.debug('Retrying Sending action %r (account: %r, interface: %r, method: %r, retry: %r)', action.event, action.account, interface, method, retry_count) + result = cls.send(action, Trakt[interface][method], request) + break + except Exception as ex: + log.error('Unable to send action %r: %r', action.event, ex, exc_info=True) if not result: # Invalid response