for task in tasks:
task.cancel()
results = await asyncio.gather(*tasks, return_exceptions=True)
- await close_tcp_connections(
+ close_tcp_connections(
result for result in results if isinstance(result, socket.socket)
)
raise AssertionError(f"timed out opening {count} TCP connections") from exc
]
errors = [result for result in results if isinstance(result, BaseException)]
if errors:
- await close_tcp_connections(connections)
+ close_tcp_connections(connections)
raise AssertionError(
f"{len(errors)} TCP connection(s) failed: {errors[0]!r}"
)
closing = self.connections[:count]
del self.connections[:count]
- await close_tcp_connections(closing)
+ close_tcp_connections(closing)
def create_socket(host: str, port: int) -> socket.socket:
return sock
-async def close_tcp_connections(connections: Iterable[socket.socket]) -> None:
+def close_tcp_connections(connections: Iterable[socket.socket]) -> None:
for sock in connections:
sock.close()
- await asyncio.sleep(0)
def wait_for_tcp_status(