pulsar-client-python icon indicating copy to clipboard operation
pulsar-client-python copied to clipboard

Disposing of a Python Consumer object without calling close() leaks file descriptors and does not close the consumer.

Open zbentley opened this issue 2 years ago • 3 comments

Describe the bug If a Python pulsar-client Consumer object is destroyed (garbage collected) without its close() method being called, the consumer remains connected, and its file descriptors remain open.

To Reproduce Steps to reproduce the behavior:

  1. Run the below snippet.
  2. Observe that it segfaults (due to https://github.com/apache/pulsar/issues/14582).
import logging
import resource
import pulsar

def main():
    resource.setrlimit(resource.RLIMIT_NOFILE, (15, 15))
    for i in range(100):
        client = pulsar.Client(service_url='pulsar://localhost', logger=logging.getLogger())
        print(f"creating mysub-{i}")
        con = client.subscribe(topic='mytopic', subscription_name=f'mysub-{i}')


if __name__ == '__main__':
    main()

Expected behavior Garbage collecting consumers should result in their no longer being present on the system.

Desktop (please complete the following information):

  • OS: MacOS Monterey (x86)
  • Pulsar client 2.9.1

zbentley avatar Mar 07 '22 15:03 zbentley

The issue had no activity for 30 days, mark with Stale label.

github-actions[bot] avatar Apr 15 '22 02:04 github-actions[bot]

The issue had no activity for 30 days, mark with Stale label.

github-actions[bot] avatar May 28 '22 02:05 github-actions[bot]

It seems this issue is still relevant. Moved to the new dedicated client repo.

tisonkun avatar Nov 11 '22 09:11 tisonkun