This is an automated email from the ASF dual-hosted git repository.

xyz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-client-python.git


The following commit(s) were added to refs/heads/main by this push:
     new b1c9487  feat: add producer connectivity functionality (#286)
b1c9487 is described below

commit b1c94879328ea6eadbda7abd8ae0c20d293cd226
Author: Nikolas Achatz <[email protected]>
AuthorDate: Tue Jan 27 22:59:28 2026 -0800

    feat: add producer connectivity functionality (#286)
---
 pulsar/asyncio.py     | 6 ++++++
 tests/asyncio_test.py | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/pulsar/asyncio.py b/pulsar/asyncio.py
index 34377d6..a1ca0c0 100644
--- a/pulsar/asyncio.py
+++ b/pulsar/asyncio.py
@@ -220,6 +220,12 @@ class Producer:
         message was ever published.
         """
         return self._producer.last_sequence_id()
+    
+    def is_connected(self) -> bool:
+        """
+        Check if the producer is connected or not.
+        """
+        return self._producer.is_connected()
 
 class Consumer:
     """
diff --git a/tests/asyncio_test.py b/tests/asyncio_test.py
index d1c923a..4440809 100644
--- a/tests/asyncio_test.py
+++ b/tests/asyncio_test.py
@@ -157,6 +157,13 @@ class AsyncioTest(IsolatedAsyncioTestCase):
         except PulsarException as e:
             self.assertEqual(e.error(), pulsar.Result.AlreadyClosed)
 
+    async def test_producer_is_connected(self):
+        topic = f'asyncio-test-producer-is-connected-{time.time()}'
+        producer = await self._client.create_producer(topic)
+        self.assertTrue(producer.is_connected())
+        await producer.close()
+        self.assertFalse(producer.is_connected())
+
     async def _prepare_messages(self, producer: Producer) -> 
List[pulsar.MessageId]:
         msg_ids = []
         for i in range(5):

Reply via email to