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

Handle WebSocketClosedError and fix indentation error #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rectalogic
Copy link

Using sockjs-tornado==1.0.7 with tornado==6.2, we see millions of exceptions of the form:

  File "/site/venv/lib/python3.10/site-packages/sockjs/tornado/periodic.py", line 69, in _run
    next_call = self.callback()
  File "/site/venv/lib/python3.10/site-packages/sockjs/tornado/session.py", line 405, in _heartbeat
    self.handler.send_pack(proto.HEARTBEAT)
  File "/site/venv/lib/python3.10/site-packages/sockjs/tornado/transports/websocket.py", line 89, in send_pack
    self.write_message(message, binary)
  File "/site/venv/lib/python3.10/site-packages/tornado/websocket.py", line 336, in write_message
    raise WebSocketClosedError()

sockjs-tornado handles IOError but tornado is raising WebSocketClosedError. This PR handles both errors.

While fixing this, I also encountered and fixed this exception due to an incorrect indentation in sockjs/tornado/transports/htmlfile.py:

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/cureatr/dev/cureatr/server/notification/web/notification_server.py", line 11, in <module>
    from sockjs.tornado import SockJSRouter
  File "/tmp/sockjs-tornado/sockjs/tornado/__init__.py", line 3, in <module>
    from .router import SockJSRouter
  File "/tmp/sockjs-tornado/sockjs/tornado/router.py", line 11, in <module>
    from sockjs.tornado import transports, session, sessioncontainer, static, stats, proto
  File "/tmp/sockjs-tornado/sockjs/tornado/transports/__init__.py", line 10, in <module>
    from .htmlfile import HtmlFileTransport
  File "/tmp/sockjs-tornado/sockjs/tornado/transports/htmlfile.py", line 69
    self.set_status(500)
                        ^
IndentationError: unindent does not match any outer indentation level

Also fix indentation error in htmlfile.py
@anvouk
Copy link

anvouk commented Jan 3, 2024

Hi @mrjoes, what do we need to do to make this pr merged and a new version tagged on pypi? the missing on_close call is quite the pain in the butt, and i'd prefer not to fork the entire repo over a single line of code... Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants