Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug in websocket close callback #343

Merged
merged 1 commit into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pytest-cov==2.8.1
pytest-mock==1.11.2
pytest==5.2.2
six==1.12.0 # via packaging
typing-extensions==3.7.4 # via aiohttp
typing-extensions==3.7.4.1 # via aiohttp
wcwidth==0.1.7 # via pytest
yarl==1.3.0 # via aiohttp
zipp==0.6.0 # via importlib-metadata
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ujson==1.35 # via sanic
urllib3==1.25.6 # via kubernetes, requests
uvloop==0.13.0 # via sanic
websocket-client==0.56.0 # via kubernetes
websockets==7.0
websockets==8.0.2

# The following packages are considered to be unsafe in a requirements file:
# setuptools==41.4.0 # via kubernetes, protobuf
# setuptools==41.6.0 # via kubernetes, protobuf
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'sanic>=0.8.0',
'prometheus-client',
'structlog',
'websockets==7.0', # fixme: temporarily pin
'websockets',
'synse-grpc==3.0.0a4', # fixme: for alpha v3 testing; update to stable v3 release
],
zip_safe=False,
Expand Down
7 changes: 5 additions & 2 deletions synse_server/api/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ def __init__(self, ws):

# When the websocket is cancelled or terminates, ensure that the MessageHandler
# associated with that websocket is stopped and cleaned up.
if ws.close_connection_task is not None:
#
# As of websockets==8.0.0, the `close_connection_task` member will not exit until
# the client is connected. Check both that the attribute exists and that it is not
# None before attempting to add a done callback to the task.
if hasattr(ws, 'close_connection_task') and ws.close_connection_task is not None:
ws.close_connection_task.add_done_callback(self.stop)

# todo - if this don't work, just use threads.
self.tasks = []

async def run(self):
Expand Down