jvstein opened a new issue, #122:
URL: https://github.com/apache/pulsar-client-python/issues/122
#### Describe the bug
The example code in the python client's `send_async` method does not work
for processes that end.
The example needs a `producer.flush()` call, but adding it introduces a
deadlock.
#### To Reproduce
Run this modified version of the example code against a pulsar cluster. Note
the change from `while True` to `for i in range(500000)` and the introduction
of the `producer.flush()` call. The `flush` call is necessary to correctly
produce all messages. If omitted, some messages will be skipped.
<details>
<summary>Code snippet</summary>
```python
import pulsar
client = pulsar.Client('pulsar://localhost:6650')
producer = client.create_producer(
'my-topic',
block_if_queue_full=True,
batching_enabled=True,
batching_max_publish_delay_ms=10)
def callback(res, msg_id):
print('Message published res=%s', res)
for i in range(500000):
producer.send_async(('Hello-%d' % i).encode('utf-8'), callback)
producer.flush()
client.close()
```
<details>
#### Desktop (please complete the following information):
pulsar-client==3.1.0
Python 3.9.13
Ubuntu 22.04.2 LTS
Pulsar 3.0.0 running in a Kubernetes cluster; client connected via
pulsar-proxy running as a LoadBalancer Service
#### Additional context / Fix
Adding a `time.sleep(1)` before the `producer.flush()` call allows the
process to exit cleanly every time that I've tested. This seems to suggest that
the deadlock occurs somewhere between trying to clear the active batch and
trying to flush the producer.
Possibly related: https://github.com/apache/pulsar/issues/5666
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]