Skip to content

Commit 46cb96e

Browse files
committed
refactor: Route interrupt() through the shared connection-close helper
1 parent 8d0de4e commit 46cb96e

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

ld_eventsource/sse_client.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,11 @@ def interrupt(self):
164164
"""
165165
if self.__connection_result:
166166
self.__interrupted = True
167-
self.__connection_result.close()
168-
self.__connection_result = None
167+
self._close_current_connection()
169168
self._compute_next_retry_delay()
170169

171170
def _close_current_connection(self):
172-
# Close the current connection before dropping it so a fault-driven reconnect tears
173-
# the old connection down deterministically (on urllib3 2.x) rather than deferring to
174-
# garbage collection. This is only reached after the read loop has ended (stream
175-
# exhausted or errored), so the reader is not blocked mid-read and closing cannot
176-
# deadlock. Capture into a local and guard for None in case interrupt() nulled it
177-
# concurrently; ConnectionResult.close() is idempotent, so a later interrupt()/close()
178-
# is safe.
171+
# Close and drop the current connection, if any.
179172
result = self.__connection_result
180173
self.__connection_result = None
181174
if result is not None:

0 commit comments

Comments
 (0)