Skip to content

Commit

Permalink
Improve waiting for transport/protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenLooman committed Jan 24, 2025
1 parent ee50f79 commit 25972b6
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions async_upnp_client/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,19 +859,15 @@ async def async_stop(self) -> None:

async def async_wait_for_transport_protocol(self) -> None:
"""Wait for the protocol to become available."""
loop = 0
max_loops = 5
while loop < max_loops:
await asyncio.sleep(0.1)
for _ in range(0, 5):
if (
self._transport is not None
and self._transport.get_protocol() is not None
):
break

loop += 1

if loop > max_loops:
await asyncio.sleep(0.1)

Check warning on line 869 in async_upnp_client/server.py

View check run for this annotation

Codecov / codecov/patch

async_upnp_client/server.py#L869

Added line #L869 was not covered by tests
else:
raise UpnpError("Failed to get protocol")

Check warning on line 871 in async_upnp_client/server.py

View check run for this annotation

Codecov / codecov/patch

async_upnp_client/server.py#L871

Added line #L871 was not covered by tests

def _announce_next(self) -> None:
Expand Down

0 comments on commit 25972b6

Please sign in to comment.