The reason is caused by the `client.close()` not being called. You should make sure `client.close()` is called when receiving a SIGINT signal.
``` #8 0x00007f194f6aca99 in pulsar::ConsumerImpl::shutdown() [clone .cold] () from /usr/local/lib/python3.7/site-packages/pulsar_client.libs/libpulsar-c7b16888.so #9 0x00007f194f79dd74 in pulsar::ConsumerImpl::~ConsumerImpl() () from /usr/local/lib/python3.7/site-packages/pulsar_client.libs/libpulsar-c7b16888.so #10 0x00007f195006a71b in pybind11::class_<pulsar::Consumer>::dealloc(pybind11::detail::value_and_holder&) () from /usr/local/lib/python3.7/site-packages/_pulsar.cpython-37m-x86_64-linux-gnu.so #11 0x00007f1950039f8e in pybind11::detail::clear_instance(_object*) () from /usr/local/lib/python3.7/site-packages/_pulsar.cpython-37m-x86_64-linux-gnu.so #12 0x00007f195003ac5f in pybind11_object_dealloc () from /usr/local/lib/python3.7/site-packages/_pulsar.cpython-37m-x86_64-linux-gnu.so #13 0x00007f1950a47927 in dict_dealloc (mp=0x7f194f302320) at Objects/dictobject.c:1905 #14 0x00007f1950acc284 in subtype_clear (self=<Consumer at remote 0x7f1950273cd0>) at Objects/typeobject.c:1123 #15 0x00007f1950aa793d in delete_garbage (old=0x7f1950c4a000 <_PyRuntime+448>, collectable=0x7fff65e5b2a0) at Modules/gcmodule.c:761 #16 collect (generation=2, n_collected=0x0, n_uncollectable=0x0, nofail=1) at Modules/gcmodule.c:913 #17 0x00007f1950af92a2 in _PyGC_CollectNoFail () at Modules/gcmodule.c:1602 #18 0x00007f1950aec340 in PyImport_Cleanup () at Python/import.c:526 #19 0x00007f1950aee5a8 in Py_FinalizeEx () at Python/pylifecycle.c:1199 #20 0x00007f1950af6b48 in pymain_main (pymain=0x7fff65e5b510) at Modules/main.c:3127 #21 0x00007f1950af6a1e in _Py_UnixMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:3160 #22 0x00007f1950768d0a in __libc_start_main (main=0x55e11cf1b050 <main>, argc=2, argv=0x7fff65e5b668, --Type <RET> for more, q to quit, c to continue without paging-- t>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff65e5b658) at ../csu/libc-start.c:308 #23 0x000055e11cf1b08a in _start () ``` I think it should not be a blocker, we can open an issue for that. The official example uses a try-except block to avoid this issue. Thanks, Yunze On Thu, Mar 9, 2023 at 9:48 PM Yunze Xu <y...@streamnative.io> wrote: > > Hi Zike, > > Did you run the latest example? I still see the exceptional info: > > ``` > line 1243, in receive > msg = self._consumer.receive() > _pulsar.Interrupted: Pulsar error: ResultInterrupted > ``` > > However, with the latest example, the output should be the following > logs if you pressed the Ctrl+C: > > ``` > ^CStop receiving messages > ``` > > Because the exception from `consumer.receive()` is caught. > > ```python3 > try: > msg = consumer.receive() > # ... > except pulsar.Interrupted: > print("Stop receiving messages") > break > ``` > > Thanks, > Yunze > > On Thu, Mar 9, 2023 at 3:02 PM Zike Yang <z...@apache.org> wrote: > > > > Hi Yunze > > > > The crash issue still exists in python 3.7. Here is the log > > ``` > > ^CTraceback (most recent call last): > > File > > "/Users/aaronrobert/codebase/pulsar-client-python/examples/consumer.py", > > line 32, in <module> > > msg = consumer.receive() > > File > > "/Users/aaronrobert/.pyenv/versions/3.7.16/lib/python3.7/site-packages/pulsar/__init__.py", > > line 1243, in receive > > msg = self._consumer.receive() > > _pulsar.Interrupted: Pulsar error: ResultInterrupted > > 2023-03-09 12:18:14.326 WARN [0x110900600] ConsumerImpl:126 | > > [persistent://public/default/my-topic, my-subscription, 0] Destroyed > > consumer which was not properly closed > > 2023-03-09 12:18:14.326 INFO [0x110900600] ConsumerImpl:134 | > > [persistent://public/default/my-topic, my-subscription, 0] Closed > > consumer for race condition: 0 > > libc++abi: terminating with uncaught exception of type > > std::__1::bad_weak_ptr: bad_weak_ptr > > [1] 52874 abort python37 > > ~/codebase/pulsar-client-python/examples/consumer.py > > ``` > > > > This issue also exists in python 3.10.8. But it worked fine when I > > upgraded it to the latest version of python 3.10: 3.10.10. > > However, python 3.7.16, which is the latest version of python 3.7 > > still not working. > > > > Not sure if it's a python issue, but only some python versions have > > fixed it. Could you take a look again? > > > > Thanks, > > Zike Yang > > > > On Wed, Mar 8, 2023 at 5:51 PM Yunze Xu <y...@streamnative.io.invalid> > > wrote: > > > > > > This is the 4th release candidate for Apache Pulsar Client Python, > > > version 3.1.0. > > > > > > It fixes the following issues: > > > https://github.com/apache/pulsar-client-python/milestone/2?closed=1 > > > > > > *** Please download, test and vote on this release. This vote will > > > stay open for at least 72 hours *** > > > > > > Python wheels: > > > https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-python-3.1.0-candidate-4/ > > > > > > The supported python versions are 3.7, 3.8, 3.9, 3.10 and 3.11. The > > > supported platforms and architectures are: > > > - Windows x86_64 (windows/) > > > - glibc-based Linux x86_64 (linux-glibc-x86_64/) > > > - glibc-based Linux arm64 (linux-glibc-arm64/) > > > - musl-based Linux x86_64 (linux-musl-x86_64/) > > > - musl-based Linux arm64 (linux-musl-arm64/) > > > - macOS universal 2 (macos/) > > > > > > You can download the wheel (the `.whl` file) according to your own OS > > > and Python version > > > and install the wheel: > > > - Windows: `py -m pip install *.whl --force-reinstall` > > > - Linux or macOS: `python3 -m pip install *.whl --force-reinstall` > > > > > > The tag to be voted upon: v3.1.0-candidate-4 > > > (b883f42aa4287d46423b85f7af77f604cacf2a7e) > > > https://github.com/apache/pulsar-client-python/releases/tag/v3.1.0-candidate-4 > > > > > > Pulsar's KEYS file containing PGP keys you use to sign the release: > > > https://downloads.apache.org/pulsar/KEYS > > > > > > Please download the Python wheels and follow the README to test.