Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pilotprotocol/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ def read_event(conn):
else:
yield (event_topic, event_data)
except Exception as e:
if "connection closed" in str(e).lower() or "EOF" in str(e):
if isinstance(e, PilotError) and "connection closed" in str(e).lower():
break
raise
finally:
Expand Down
9 changes: 6 additions & 3 deletions tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,15 +406,18 @@ def read(self, size: int = 4096) -> bytes:
assert events == []
assert conn.closed is True

def test_eof_error_breaks_cleanly(self, monkeypatch):
def test_eof_error_propagates(self, monkeypatch):
# RuntimeError containing "EOF" is NOT a clean disconnect —
# only PilotError("connection closed") should be silenced.
class EofConn(FakeConn):
def read(self, size: int = 4096) -> bytes:
raise RuntimeError("unexpected EOF on stream")

conn = EofConn()
d = _make_driver_with_dial(monkeypatch, conn)
events = list(d.subscribe_event("0:0001.0000.0002", "t", timeout=2))
assert events == []
with pytest.raises(RuntimeError, match="unexpected EOF on stream"):
list(d.subscribe_event("0:0001.0000.0002", "t", timeout=2))
assert conn.closed is True

def test_other_exception_propagates(self, monkeypatch):
# Error string contains neither "connection closed" nor "EOF" —
Expand Down
Loading