From 564ee2bd9b832003deb669263de9cd379ea15503 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Wed, 17 Jan 2024 23:30:45 -0700 Subject: [PATCH] event listener: disable timeout on request The timeout is now on waiting for a line (which is 20 seconds) and that should only happen if we aren't getting heartbeats or other messages. Signed-off-by: Sumner Evans --- linkedin_messaging/linkedin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linkedin_messaging/linkedin.py b/linkedin_messaging/linkedin.py index 800cbed..de84db1 100644 --- a/linkedin_messaging/linkedin.py +++ b/linkedin_messaging/linkedin.py @@ -126,7 +126,7 @@ class LinkedInMessaging: list[ Union[ Callable[[RealTimeEventStreamEvent], Awaitable[None]], - Callable[[asyncio.exceptions.TimeoutError], Awaitable[None]], + Callable[[asyncio.TimeoutError], Awaitable[None]], Callable[[Exception], Awaitable[None]], ] ], @@ -525,7 +525,7 @@ def add_event_listener( payload_key: str, fn: Union[ Callable[[RealTimeEventStreamEvent], Awaitable[None]], - Callable[[asyncio.exceptions.TimeoutError], Awaitable[None]], + Callable[[asyncio.TimeoutError], Awaitable[None]], Callable[[Exception], Awaitable[None]], ], ): @@ -554,6 +554,7 @@ async def _listen_to_event_stream(self): REALTIME_CONNECT_URL, headers=headers, params={"rc": "1"}, + timeout=aiohttp.ClientTimeout(total=None), ) as resp: if resp.status != 200: raise TooManyRequestsError(f"Failed to connect. Status {resp.status}.")