Skip to content

Commit

Permalink
Update max time for backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
fbradyirl committed Apr 24, 2024
1 parent 8e338d3 commit d352c78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
with open('README.md') as readme_file:
readme = readme_file.read()

# For latest unreleased version use
# `webexteamssdk@ git+https://github.com/WebexCommunity/WebexPythonSDK.git`
requirements = ['webexteamssdk==1.6.1', 'coloredlogs', 'websockets==10.2', 'backoff']

setup_requirements = ['pytest-runner', ]
Expand Down
9 changes: 5 additions & 4 deletions webex_bot/websockets/webex_websocket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
ssl_context = ssl.create_default_context()
ssl_context.load_verify_locations(certifi.where())

MAX_BACKOFF_TIME = 240

class WebexWebsocketClient(object):
def __init__(self,
Expand Down Expand Up @@ -151,10 +152,10 @@ async def _websocket_recv():
logger.warning(
f"An exception occurred while processing message. Ignoring. {messageProcessingException}")

@backoff.on_exception(backoff.expo, websockets.ConnectionClosedError)
@backoff.on_exception(backoff.expo, websockets.ConnectionClosedOK)
@backoff.on_exception(backoff.expo, websockets.ConnectionClosed)
@backoff.on_exception(backoff.expo, socket.gaierror)
@backoff.on_exception(backoff.expo, websockets.ConnectionClosedError, max_time=MAX_BACKOFF_TIME)
@backoff.on_exception(backoff.expo, websockets.ConnectionClosedOK, max_time=MAX_BACKOFF_TIME)
@backoff.on_exception(backoff.expo, websockets.ConnectionClosed, max_time=MAX_BACKOFF_TIME)
@backoff.on_exception(backoff.expo, socket.gaierror, max_time=MAX_BACKOFF_TIME)
async def _connect_and_listen():
ws_url = self.device_info['webSocketUrl']
logger.info(f"Opening websocket connection to {ws_url}")
Expand Down

0 comments on commit d352c78

Please sign in to comment.