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

Python 3.11 incompatible with websockets\legacy\protocol.py Error "got an unexpected keyword argument 'loop'" #1456

Closed
normanlmfung opened this issue Apr 1, 2024 · 1 comment

Comments

@normanlmfung
Copy link

Python 3.11 incompatible with websockets\legacy\protocol.py
Error "got an unexpected keyword argument 'loop'"

The following places is where this happens, fix is simply remove 'loop' argument.
WebSocketCommonProtocol.init
FROM:
self._drain_lock = asyncio.Lock(
loop=loop if sys.version_info[:2] < (3, 8) else None
)
TO:
self._drain_lock = asyncio.Lock()

WebSocketCommonProtocol.close
FROM:
await asyncio.wait_for(
self.write_close_frame(serialize_close(code, reason)),
self.close_timeout,
loop=self.loop if sys.version_info[:2] < (3, 8) else None,
)
TO:
await asyncio.wait_for(
self.write_close_frame(serialize_close(code, reason)),
self.close_timeout
)

WebSocketCommonProtocol.wait_for_connection_lost
FROM:
await asyncio.wait_for(
asyncio.shield(self.connection_lost_waiter),
self.close_timeout,
loop=self.loop if sys.version_info[:2] < (3, 8) else None,
)
TO:
await asyncio.wait_for(
asyncio.shield(self.connection_lost_waiter),
self.close_timeout,
)

WebSocketCommonProtocol.recv
FROM:
await asyncio.wait(
[pop_message_waiter, self.transfer_data_task],
loop=self.loop if sys.version_info[:2] < (3, 8) else None,
return_when=asyncio.FIRST_COMPLETED,
)
TO:
await asyncio.wait(
[pop_message_waiter, self.transfer_data_task],
return_when=asyncio.FIRST_COMPLETED,
)
WebSocketCommonProtocol.keepalive_ping
FROM:
await asyncio.sleep(
self.ping_interval,
loop=self.loop if sys.version_info[:2] < (3, 8) else None,
)
await asyncio.wait_for(
pong_waiter,
self.ping_timeout,
loop=self.loop if sys.version_info[:2] < (3, 8) else None,
)
TO:
await asyncio.sleep(
self.ping_interval
)
await asyncio.wait_for(
pong_waiter,
self.ping_timeout
)

@aaugustin
Copy link
Member

Which version of websockets are you using?

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

No branches or pull requests

2 participants