Skip to content

Commit a9f1acd

Browse files
authored
Fix unsubscription when not yet subscribed (#103)
1 parent 6f21b5a commit a9f1acd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/faststream-stomp/faststream_stomp/subscriber.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def __init__(
3939
self.headers = headers
4040
self.on_suppressed_exception = on_suppressed_exception
4141
self.suppressed_exception_classes = suppressed_exception_classes
42+
self._subscription: stompman.Subscription | None = None
43+
4244
super().__init__(
4345
no_ack=self.ack == "auto",
4446
no_reply=True,
@@ -93,7 +95,8 @@ async def start(self) -> None:
9395
)
9496

9597
async def close(self) -> None:
96-
await self._subscription.unsubscribe()
98+
if self._subscription:
99+
await self._subscription.unsubscribe()
97100
await super().close()
98101

99102
async def get_one(self, *, timeout: float = 5) -> None: ...

0 commit comments

Comments
 (0)