websockets icon indicating copy to clipboard operation
websockets copied to clipboard

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

Open normanlmfung opened this issue 1 year ago • 1 comments

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 )

normanlmfung avatar Apr 01 '24 03:04 normanlmfung

Which version of websockets are you using?

aaugustin avatar Apr 05 '24 13:04 aaugustin