Skip to content

Commit 012cb1a

Browse files
authored
fix (#2013): allow to create publisher in already connected broker (#2024)
* fix: allow to create publisher in connected broker * chore: bump version
1 parent 8e86a8c commit 012cb1a

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

faststream/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Simple and fast framework to create message brokers based microservices."""
22

3-
__version__ = "0.5.33"
3+
__version__ = "0.5.34"
44

55
SERVICE_NAME = f"faststream-{__version__}"

faststream/broker/core/usecase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def _publisher_setup_extra(self) -> "AnyDict":
285285

286286
def publisher(self, *args: Any, **kwargs: Any) -> "PublisherProto[MsgType]":
287287
pub = super().publisher(*args, **kwargs)
288-
if self.running:
288+
if self.running or self._connection is not None:
289289
self.setup_publisher(pub)
290290
return pub
291291

tests/brokers/base/publish.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,12 @@ async def handler(m):
578578
assert event.is_set()
579579
assert not mock.called
580580

581+
@pytest.mark.asyncio
582+
async def test_publisher_after_connect(self, queue: str):
583+
async with self.patch_broker(self.get_broker()) as br:
584+
# Should pass without error
585+
await br.publisher(queue).publish(None)
586+
581587
@pytest.mark.asyncio
582588
async def test_publisher_after_start(
583589
self,

0 commit comments

Comments
 (0)