tags 1008598 + patch thanks I attach a patch to fix the issue.
I tested locally and it seems to be working fine for me. Best. -- Salvo Tomaselli "Io non mi sento obbligato a credere che lo stesso Dio che ci ha dotato di senso, ragione ed intelletto intendesse che noi ne facessimo a meno." -- Galileo Galilei http://ltworf.github.io/ltworf/
Description: This passes the loop parameter only on the supported versions The loop parameter has been deprecated for years. . This library is buggy, and on the versions where the parameter is deprecated it passes a None. . This actually broke when the parameter was removed for real, since the parameter should not be passed at all instead. Bug-Debian: #1008598 From: Salvo 'LtWorf' Tomaselli <tipos...@tiscali.it> --- python-websockets-9.1.orig/src/websockets/legacy/protocol.py +++ python-websockets-9.1/src/websockets/legacy/protocol.py @@ -151,8 +151,11 @@ class WebSocketCommonProtocol(asyncio.Pr self._paused = False self._drain_waiter: Optional[asyncio.Future[None]] = None + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop self._drain_lock = asyncio.Lock( - loop=loop if sys.version_info[:2] < (3, 8) else None + **kwloop ) # This class implements the data transfer and closing handshake, which @@ -225,6 +228,9 @@ class WebSocketCommonProtocol(asyncio.Pr raise exc if self.transport is not None: if self.transport.is_closing(): + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop # Yield to the event loop so connection_lost() may be # called. Without this, _drain_helper() would return # immediately, and code that calls @@ -232,7 +238,7 @@ class WebSocketCommonProtocol(asyncio.Pr # in a loop would never call connection_lost(), so it # would not see an error when the socket is closed. await asyncio.sleep( - 0, loop=self.loop if sys.version_info[:2] < (3, 8) else None + 0, **kwloop ) await self._drain_helper() @@ -399,12 +405,15 @@ class WebSocketCommonProtocol(asyncio.Pr pop_message_waiter: asyncio.Future[None] = self.loop.create_future() self._pop_message_waiter = pop_message_waiter try: + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop # If asyncio.wait() is canceled, it doesn't cancel # pop_message_waiter and self.transfer_data_task. 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, + **kwloop, ) finally: self._pop_message_waiter = None @@ -596,10 +605,13 @@ class WebSocketCommonProtocol(asyncio.Pr """ try: + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop 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, + **kwloop, ) except asyncio.TimeoutError: # If the close frame cannot be sent because the send buffers @@ -615,12 +627,15 @@ class WebSocketCommonProtocol(asyncio.Pr # Other calls will receive a CancelledError here. try: + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop # If close() is canceled during the wait, self.transfer_data_task # is canceled before the timeout elapses. await asyncio.wait_for( self.transfer_data_task, self.close_timeout, - loop=self.loop if sys.version_info[:2] < (3, 8) else None, + **kwloop, ) except (asyncio.TimeoutError, asyncio.CancelledError): pass @@ -1039,10 +1054,13 @@ class WebSocketCommonProtocol(asyncio.Pr return try: + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop while True: await asyncio.sleep( self.ping_interval, - loop=self.loop if sys.version_info[:2] < (3, 8) else None, + **kwloop, ) # ping() raises CancelledError if the connection is closed, @@ -1055,10 +1073,13 @@ class WebSocketCommonProtocol(asyncio.Pr if self.ping_timeout is not None: try: + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop await asyncio.wait_for( pong_waiter, self.ping_timeout, - loop=self.loop if sys.version_info[:2] < (3, 8) else None, + **kwloop, ) except asyncio.TimeoutError: logger.debug("%s ! timed out waiting for pong", self.side) @@ -1155,10 +1176,13 @@ class WebSocketCommonProtocol(asyncio.Pr """ if not self.connection_lost_waiter.done(): try: + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop 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, + **kwloop, ) except asyncio.TimeoutError: pass --- python-websockets-9.1.orig/src/websockets/legacy/server.py +++ python-websockets-9.1/src/websockets/legacy/server.py @@ -803,8 +803,11 @@ class WebSocketServer: # Wait until all accepted connections reach connection_made() and call # register(). See https://bugs.python.org/issue34852 for details. + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop await asyncio.sleep( - 0, loop=self.loop if sys.version_info[:2] < (3, 8) else None + 0, **kwloop ) # Close OPEN connections with status code 1001. Since the server was @@ -813,21 +816,27 @@ class WebSocketServer: # asyncio.wait doesn't accept an empty first argument if self.websockets: + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop await asyncio.wait( [ asyncio.ensure_future(websocket.close(1001)) for websocket in self.websockets ], - loop=self.loop if sys.version_info[:2] < (3, 8) else None, + **kwloop ) # Wait until all connection handlers are complete. # asyncio.wait doesn't accept an empty first argument. if self.websockets: + kwloop = {} + if sys.version_info[:2] < (3, 8): + kwloop['loop'] = self.loop await asyncio.wait( [websocket.handler_task for websocket in self.websockets], - loop=self.loop if sys.version_info[:2] < (3, 8) else None, + **kwloop, ) # Tell wait_closed() to return.