-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
- Python version: 3.9.2
- Operating System: Debian 10
- aiohttp version: 3.8.1
Description
Client connection failure is not handled properly when I'm trying to connect to a server which is not running.
What I Did
import asyncio
from aiohttp_sse_client import client as sse_client
async def main():
async with sse_client.EventSource(
url="http://no-such-url", max_connect_retry=1
) as event_source:
async for event in event_source:
print(event)
asyncio.run(main())
# aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host no-such-url:80 ssl:default [Name or service not known]
# Unclosed client session
# client_session: <aiohttp.client.ClientSession object at 0x7f9c9e5d7070>Temporary solution - passing custom session object. The session is getting closed after exception raised.
import asyncio
from aiohttp import ClientSession
from aiohttp_sse_client import client as sse_client
async def main():
url = "http://no-such-url"
async with ClientSession() as session:
async with sse_client.EventSource(
url=url, session=session, max_connect_retry=1
) as event_source:
async for event in event_source:
print(event)
asyncio.run(main())Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels