Skip to content
Open
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
10 changes: 10 additions & 0 deletions pulsar/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,16 @@ async def subscribe(self, topic: Union[str, List[str]],

schema.attach_client(self._client)
return Consumer(await future, schema)

def shutdown(self) -> None:
"""
Shutdown the client and all the associated producers and consumers

Raises
------
PulsarException
"""
self._client.shutdown()

async def close(self) -> None:
"""
Expand Down
12 changes: 12 additions & 0 deletions tests/asyncio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ async def test_producer_is_connected(self):
await producer.close()
self.assertFalse(producer.is_connected())

async def test_shutdown_client(self):
producer = await self._client.create_producer("persistent://public/default/partitioned_topic_name_test")
await producer.send(b"hello")
self._client.shutdown()

try:
await producer.send(b"hello")
self.assertTrue(False)
except PulsarException:
# Expected
pass

async def _prepare_messages(self, producer: Producer) -> List[pulsar.MessageId]:
msg_ids = []
for i in range(5):
Expand Down