Remove loop parameter from asyncio primitives -- This has been deprecated since Python 3.8

This commit is contained in:
Paulo Costa 2023-06-20 22:51:44 -03:00
parent e6d5c86efb
commit 4abb343223
5 changed files with 10 additions and 8 deletions

View file

@ -1,4 +1,4 @@
__version__ = "0.0.18" __version__ = "0.0.19"
__author__ = "Jack Robison" __author__ = "Jack Robison"
__maintainer__ = "Jack Robison" __maintainer__ = "Jack Robison"
__license__ = "MIT" __license__ = "MIT"

View file

@ -224,7 +224,7 @@ class Gateway:
try: try:
return await asyncio.wait_for(loop.create_task( return await asyncio.wait_for(loop.create_task(
cls._discover_gateway(lan_address, gateway_address, timeout, loop) cls._discover_gateway(lan_address, gateway_address, timeout, loop)
), timeout, loop=loop) ), timeout)
except asyncio.TimeoutError: except asyncio.TimeoutError:
raise UPnPError(f"M-SEARCH for {gateway_address}:1900 timed out") raise UPnPError(f"M-SEARCH for {gateway_address}:1900 timed out")

View file

@ -141,7 +141,7 @@ async def scpd_get(control_url: str, address: str, port: int,
assert isinstance(protocol, SCPDHTTPClientProtocol) assert isinstance(protocol, SCPDHTTPClientProtocol)
error = None error = None
wait_task: typing.Awaitable[typing.Tuple[bytes, bytes, int, bytes]] = asyncio.wait_for(protocol.finished, 1.0, loop=loop) wait_task: typing.Awaitable[typing.Tuple[bytes, bytes, int, bytes]] = asyncio.wait_for(protocol.finished, 1.0)
body = b'' body = b''
raw_response = b'' raw_response = b''
try: try:
@ -182,7 +182,7 @@ async def scpd_post(control_url: str, address: str, port: int, method: str, para
assert isinstance(protocol, SCPDHTTPClientProtocol) assert isinstance(protocol, SCPDHTTPClientProtocol)
try: try:
wait_task: typing.Awaitable[typing.Tuple[bytes, bytes, int, bytes]] = asyncio.wait_for(finished, 1.0, loop=loop) wait_task: typing.Awaitable[typing.Tuple[bytes, bytes, int, bytes]] = asyncio.wait_for(finished, 1.0)
raw_response, body, response_code, response_msg = await wait_task raw_response, body, response_code, response_msg = await wait_task
except asyncio.TimeoutError: except asyncio.TimeoutError:
return {}, b'', UPnPError("Timeout") return {}, b'', UPnPError("Timeout")

View file

@ -31,8 +31,8 @@ class SSDPProtocol(MulticastProtocol):
self.transport: Optional[DatagramTransport] = None self.transport: Optional[DatagramTransport] = None
self._pending_searches: List[PendingSearch] = [] self._pending_searches: List[PendingSearch] = []
self.notifications: List[SSDPDatagram] = [] self.notifications: List[SSDPDatagram] = []
self.connected = asyncio.Event(loop=self.loop) self.connected = asyncio.Event()
self.devices: 'asyncio.Queue[SSDPDatagram]' = asyncio.Queue(loop=self.loop) self.devices: 'asyncio.Queue[SSDPDatagram]' = asyncio.Queue()
def connection_made(self, transport: asyncio.DatagramTransport) -> None: # type: ignore def connection_made(self, transport: asyncio.DatagramTransport) -> None: # type: ignore
super().connection_made(transport) super().connection_made(transport)
@ -98,7 +98,7 @@ class SSDPProtocol(MulticastProtocol):
async def m_search(self, address: str, timeout: float, async def m_search(self, address: str, timeout: float,
datagrams: List[Dict[str, typing.Union[str, int]]]) -> SSDPDatagram: datagrams: List[Dict[str, typing.Union[str, int]]]) -> SSDPDatagram:
fut = self.send_m_searches(address, datagrams) fut = self.send_m_searches(address, datagrams)
return await asyncio.wait_for(fut, timeout, loop=self.loop) return await asyncio.wait_for(fut, timeout)
def datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None: # type: ignore def datagram_received(self, data: bytes, addr: Tuple[str, int]) -> None: # type: ignore
if addr[0] == self.bind_address: if addr[0] == self.bind_address:

View file

@ -24,8 +24,10 @@ setup(
"Intended Audience :: Developers", "Intended Audience :: Developers",
"License :: OSI Approved :: MIT License", "License :: OSI Approved :: MIT License",
"Operating System :: OS Independent", "Operating System :: OS Independent",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: System :: Networking", "Topic :: System :: Networking",
"Topic :: Communications :: File Sharing" "Topic :: Communications :: File Sharing"
], ],