Skip to content

Commit

Permalink
Merge pull request #11 from authorizon/raise_invalid_code
Browse files Browse the repository at this point in the history
PubSubClient: if InvalidStatusCode is raised, do not try to reconnect.
  • Loading branch information
asafc authored Mar 25, 2021
2 parents 94e4fbe + 194e84b commit bbf63f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion fastapi_websocket_pubsub/pub_sub_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,16 @@ async def run(self, uri, wait_on_reader=True):
except websockets.exceptions.WebSocketException as err:
logger.info(f"Connection failed with - {err}. -- Trying to reconnect.")
except asyncio.exceptions.CancelledError:
logger.info(f"Connection was actively canceled -- won't try to reconnect.")
logger.info(f"Connection was actively canceled -- Won't try to reconnect.")
# clean exit (no retrying)
# better support for keyboard interrupt
return
except:
# log unhandled exceptions (which will be swallowed by the with statement otherwise )
logger.exception(f"Unknown PubSub error -- Trying to reconnect.")
except websockets.exceptions.InvalidStatusCode as err:
logger.exception(f"Connection failed with an invalid status code - {err.status_code} -- Won't try to reconnect.")
raise
except:
logger.exception(f"Unknown PubSub init error -- Trying to reconnect.")

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
fastapi-websocket-rpc>=0.1.16
fastapi-websocket-rpc>=0.1.17
broadcaster==0.2.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def get_requirements(env=""):

setup(
name='fastapi_websocket_pubsub',
version='0.1.15',
version='0.1.16',
author='Or Weis',
author_email="[email protected]",
description="A fast and durable PubSub channel over Websockets (using fastapi-websockets-rpc).",
Expand All @@ -25,7 +25,7 @@ def get_requirements(env=""):
"Operating System :: OS Independent",
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
"Topic :: Internet :: WWW/HTTP :: WSGI"
],
],
python_requires='>=3.7',
install_requires=get_requirements(),
)

0 comments on commit bbf63f9

Please sign in to comment.