Skip to content

Commit

Permalink
More robustness when the connection is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed May 15, 2021
1 parent 00c655a commit 1a323e5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/flask_sock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ def route(self, path, **kwargs):
def decorator(f):
@wraps(f)
def websocket_route(*args, **kwargs):
ws = Server(request.environ)
try:
f(Server(request.environ), *args, **kwargs)
f(ws, *args, **kwargs)
except ConnectionClosed:
pass
try:
ws.close()
except:
pass
return ''

kwargs['websocket'] = True
Expand Down

0 comments on commit 1a323e5

Please sign in to comment.