1
1
import threading
2
- import time
3
2
from typing import Callable , Optional
4
3
5
4
from ld_eventsource import SSEClient
@@ -25,7 +24,6 @@ def __init__(
25
24
event_processor : StreamingEventProcessor ,
26
25
on_ready : Optional [Callable [[], None ]] = None ,
27
26
sse_client_factory : Optional [Callable [[str , dict , int ], SSEClient ]] = None ,
28
- heartbeat_timeout : int = 60 ,
29
27
backoff_initial : float = 2.0 ,
30
28
backoff_max : float = 30.0 ,
31
29
backoff_multiplier : float = 2.0 ,
@@ -37,7 +35,6 @@ def __init__(
37
35
self ._timeout = request_timeout
38
36
self ._on_ready = on_ready
39
37
self ._sse_factory = sse_client_factory
40
- self ._hb_timeout = heartbeat_timeout
41
38
self ._backoff_initial = backoff_initial
42
39
self ._backoff_max = backoff_max
43
40
self ._backoff_multiplier = backoff_multiplier
@@ -99,16 +96,12 @@ def _run(self): # noqa: PLR0912
99
96
logger = LOGGER ,
100
97
)
101
98
102
- last_event_time = time .time ()
103
-
104
99
for event in client .events :
105
100
if self ._stop .is_set ():
106
101
break
107
102
if not event .event :
108
103
continue
109
104
110
- last_event_time = time .time ()
111
-
112
105
self ._processor .process (event )
113
106
if event .event == "unleash-connected" and self ._processor .hydrated :
114
107
if self ._on_ready :
@@ -117,15 +110,6 @@ def _run(self): # noqa: PLR0912
117
110
except Exception as cb_exc : # noqa: BLE001
118
111
LOGGER .debug ("Ready callback error: %s" , cb_exc )
119
112
120
- if self ._hb_timeout and (
121
- time .time () - last_event_time > self ._hb_timeout
122
- ):
123
- LOGGER .warning ("Heartbeat timeout exceeded; reconnecting" )
124
- try :
125
- client .interrupt () # Don't break, rely on SSE client retry
126
- except Exception : # noqa: BLE001
127
- break
128
-
129
113
LOGGER .debug ("SSE stream ended" )
130
114
131
115
except Exception as exc : # noqa: BLE001
0 commit comments