sanic-org/sanic

ImportError: cannot import name 'CLOSED' from 'websockets.connection'

Closed

#2,733 opened on Apr 3, 2023

 (4 comments) (1 reaction) (0 assignees)Python (1,515 forks)batch import
beginnerbughelp wanted

Repository metrics

Stars
 (17,623 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

We're using Sanic 21.12.2 at rasa and notice this bug whenever rasa tries to spin a sanic server,

File "/Users/zi/Work/Rasa/venv-rasa-oss-3-10-2/lib/python3.10/site-packages/sanic/mixins/startup.py", line 57, in <module>
    from sanic.server.protocols.websocket_protocol import WebSocketProtocol
  File "/Users/zi/Work/Rasa/venv-rasa-oss-3-10-2/lib/python3.10/site-packages/sanic/server/protocols/websocket_protocol.py", line 3, in <module>
    from websockets.connection import CLOSED, CLOSING, OPEN
ImportError: cannot import name 'CLOSED' from 'websockets.connection' (/Users/zi/Work/Rasa/venv-rasa-oss-3-10-2/lib/python3.10/site-packages/websockets/connection.py)

It seems like https://github.com/sanic-org/sanic/pull/2609 addresses it but these changes are not available to the branch for version 21 21.12LTS.

Code snippet

No response

Expected Behavior

I would have expected to not see any error when starting the sanic server. I get expected behaviour when using sanic version 22.12.0 and 23.3.0

How do you run Sanic?

Sanic CLI

Operating System

MacOS

Sanic Version

Sanic 21.12.2; Routing 0.7.2

Additional context

No response

Contributor guide