-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
The fix for issue #2364 ("AbstractServer" has no attribute "sockets") added this declaration:
class AbstractServer:
sockets: Optional[List[socket]]However, in the Python 3.9 implementation of asyncio.base_events.Server, sockets is a property defined like this:
@property
def sockets(self):
if self._sockets is None:
return ()
return tuple(trsock.TransportSocket(s) for s in self._sockets)So we have two problems:
- The value of
socketsis neverNone, it's always atuple. - It is really a
tuple[TransportSocket, ...].
There is example code in the asyncio docs and test code in the standard library that assume sockets is a sequence of sockets.
@ymyzk contributed the patch for #2364 noting "I noticed that this class has some changes in Python 3.7, so we need to update it again in the near future."
The documentation for asyncio.Server.sockets states:
Changed in version 3.7: Prior to Python 3.7 Server.sockets used to return an internal list of server sockets directly. In 3.7 a copy of that list is returned.
As I mentioned, the actual value returned is a tuple of zero or more asyncio.Server.TransportSocket objects.