We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6055ad6 commit f3ef334Copy full SHA for f3ef334
examples/example_fastapi/main.py
@@ -198,10 +198,11 @@ async def connect_ipv6():
198
return {"result": False, "reason": str(error.args[0])}
199
200
201
-async def check_url(internet_host: HttpUrl, timeout_seconds: int = 5):
+async def check_url(internet_host: HttpUrl, timeout_seconds: int = 5, socket_family=socket.AF_INET):
202
"""Check the connectivity of a single URL."""
203
timeout = aiohttp.ClientTimeout(total=timeout_seconds)
204
- async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(), timeout=timeout) as session:
+ tcp_connector = aiohttp.TCPConnector(family=socket_family)
205
+ async with aiohttp.ClientSession(timeout=timeout, connector=tcp_connector) as session:
206
try:
207
async with session.get(internet_host) as resp:
208
resp.raise_for_status()
0 commit comments