Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist
uv.lock
.vscode
__pycache__
.idea
7 changes: 7 additions & 0 deletions packages/faststream-stomp/faststream_stomp/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def __init__(

super().__init__(config=broker_config, specification=specification, routers=routers)
self._attempted_to_connect = False
self._stopping = False

async def _connect(self) -> stompman.Client:
if self._attempted_to_connect:
Expand All @@ -154,13 +155,19 @@ async def stop(
exc_val: BaseException | None = None,
exc_tb: types.TracebackType | None = None,
) -> None:
self._stopping = True
for sub in self.subscribers:
await sub.stop()
if self._connection:
await self._connection.__aexit__(exc_type, exc_val, exc_tb)
self._stopping = False
self.running = False

async def ping(self, timeout: float | None = None) -> bool:
# broker can be stuck in stopping state
if self._stopping:
return False

sleep_time = (timeout or 10) / 10
with anyio.move_on_after(timeout) as cancel_scope:
if self._connection is None:
Expand Down