Skip to content

Conversation

vrslev
Copy link
Collaborator

@vrslev vrslev commented Jun 18, 2025

No description provided.

@vrslev
Copy link
Collaborator Author

vrslev commented Jun 18, 2025

Don't know how to test it, sadly :( Tried this:

diff --git a/packages/faststream-stomp/test_faststream_stomp/test_integration.py b/packages/faststream-stomp/test_faststream_stomp/test_integration.py
index e326fd1..d438595 100644
--- a/packages/faststream-stomp/test_faststream_stomp/test_integration.py
+++ b/packages/faststream-stomp/test_faststream_stomp/test_integration.py
@@ -225,3 +225,18 @@ async def test_broker_connect_twice(broker: faststream_stomp.StompBroker) -> Non
     app = AsgiFastStream(broker, on_startup=[broker.connect])
     async with LifespanManager(app):
         pass
+
+
+async def test_broker_connection_becomes_unavailable(
+    broker: faststream_stomp.StompBroker, monkeypatch: pytest.MonkeyPatch
+) -> None:
+    class CustomException(Exception): ...
+
+    monkeypatch.setattr("builtins.SystemExit", CustomException)
+    async with broker:
+        assert broker._connection
+        broker._connection._listen_task.get_coro().throw(
+            BaseExceptionGroup("", [stompman.FailedAllConnectAttemptsError(retry_attempts=0, issues=[])])
+        )
+        with pytest.raises(CustomException):
+            await asyncio.sleep(0)

Results in asyncio.exceptions.CancelledError

@vrslev vrslev merged commit b349d6d into main Jun 18, 2025
5 checks passed
@vrslev vrslev deleted the faststream-exit-when-unavailable branch June 18, 2025 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant