Skip to content

Commit e0b040a

Browse files
fix: prevent infinite SSE reconnection after shutdown
Set realtime_flags to False in _close_sse_connection() to stop the SSE listener thread from attempting reconnection after the client has been shut down. Without this, the check on line 2304 would still pass even after shutdown since realtime_flags remained True. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent c6d2b20 commit e0b040a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

posthog/client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2351,10 +2351,13 @@ def sse_listener():
23512351

23522352
def _close_sse_connection(self):
23532353
"""
2354-
Close the active SSE connection.
2354+
Close the active SSE connection and prevent reconnection.
23552355
"""
23562356
if self.sse_connection:
23572357
self.log.debug("[FEATURE FLAGS] Closing SSE connection")
2358+
# Disable realtime flags to prevent reconnection
2359+
self.realtime_flags = False
2360+
23582361
with self._sse_lock:
23592362
self.sse_connected = False
23602363

0 commit comments

Comments
 (0)