This repository was archived by the owner on Dec 12, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1+ # v0.5.5
2+
3+ * Add back support for the ` TIMEOUT ` special event. All other errors still need
4+ to be handled by API consumers.
5+
16# v0.5.4
27
38* Fix the ` __license__ ` property in the package.
Original file line number Diff line number Diff line change 44from .linkedin import ChallengeException , LinkedInMessaging
55
66__title__ = "linkedin_messaging"
7- __version__ = "0.5.4 "
7+ __version__ = "0.5.5 "
88__description__ = "An unofficial API for interacting with LinkedIn Messaging"
99
1010__license__ = "Apache License 2.0"
Original file line number Diff line number Diff line change @@ -498,14 +498,16 @@ def add_event_listener(
498498 payload_key : str ,
499499 fn : Union [
500500 Callable [[RealTimeEventStreamEvent ], Awaitable [None ]],
501+ Callable [[asyncio .exceptions .TimeoutError ], Awaitable [None ]],
501502 Callable [[Exception ], Awaitable [None ]],
502503 ],
503504 ):
504505 """
505- There is one special event type :
506+ There are two special event types :
506507
507508 * ``ALL_EVENTS`` - an event fired on every event, and which contains the entirety of the
508509 raw event payload
510+ * ``TIMEOUT`` - an event fired if the event listener connection times out
509511 """
510512 self .event_listeners [payload_key ].append (fn )
511513
@@ -561,6 +563,14 @@ async def start_listener(self):
561563 while True :
562564 try :
563565 await self ._listen_to_event_stream ()
566+ except asyncio .exceptions .TimeoutError as te :
567+ # Special handling for TIMEOUT handler.
568+ if timeout_handlers := self .event_listeners .get ("TIMEOUT" ):
569+ for handler in timeout_handlers :
570+ try :
571+ await handler (te )
572+ except Exception :
573+ logging .exception (f"Handler { handler } failed to handle { te } " )
564574 except Exception as e :
565575 logging .exception (f"Got exception in listener: { e } " )
566576 raise
You can’t perform that action at this time.
0 commit comments