Skip to content

Commit

Permalink
fix (#2013): allow to create publisher in already connected broker (#…
Browse files Browse the repository at this point in the history
…2024)

* fix: allow to create publisher in connected broker

* chore: bump version
  • Loading branch information
Lancetnik authored Jan 8, 2025
1 parent 8e86a8c commit 012cb1a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion faststream/__about__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Simple and fast framework to create message brokers based microservices."""

__version__ = "0.5.33"
__version__ = "0.5.34"

SERVICE_NAME = f"faststream-{__version__}"
2 changes: 1 addition & 1 deletion faststream/broker/core/usecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _publisher_setup_extra(self) -> "AnyDict":

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

Expand Down
6 changes: 6 additions & 0 deletions tests/brokers/base/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,12 @@ async def handler(m):
assert event.is_set()
assert not mock.called

@pytest.mark.asyncio
async def test_publisher_after_connect(self, queue: str):
async with self.patch_broker(self.get_broker()) as br:
# Should pass without error
await br.publisher(queue).publish(None)

@pytest.mark.asyncio
async def test_publisher_after_start(
self,
Expand Down

0 comments on commit 012cb1a

Please sign in to comment.