Skip to content

Python API: create_reader() argument reader_listener causes exception #5484

@candlerb

Description

@candlerb

Describe the bug
Python API describes option reader_listener but it causes an exception when used.

To Reproduce
Steps to reproduce the behavior:

import pulsar

client = pulsar.Client('pulsar://localhost:6650')

msg_id = pulsar.MessageId.earliest

def foo(*a, **b):
    pass
reader = client.create_reader('my-topic', msg_id, reader_listener=foo)

while True:
    msg = reader.read_next()
    print("Received message %r id=%s" % (msg.data(), msg.message_id()))

Generates the following exception:

Traceback (most recent call last):
  File "read.py", line 9, in <module>
    reader = client.create_reader('my-topic', msg_id, reader_listener=foo)
  File "/usr/local/lib/python3.6/dist-packages/pulsar/__init__.py", line 684, in create_reader
    conf.reader_listener(_listener_wrapper(reader_listener, schema))
AttributeError: 'ReaderConfiguration' object has no attribute 'reader_listener'

Expected behavior
To configure reader successfully

Screenshots
N/A

Desktop (please complete the following information):
N/A

Additional context

Issue separated out from #5365

pulsar-client-cpp/python/src/config.cc says:

    class_<ReaderConfiguration>("ReaderConfiguration")
            .def("message_listener", &ReaderConfiguration_setReaderListener, return_self<>())

But the python code in pulsar-client-cpp/python/pulsar/__init__.py calls conf.reader_listener instead:

        conf = _pulsar.ReaderConfiguration()
        if reader_listener:
            conf.reader_listener(_listener_wrapper(reader_listener, schema))

I suspect the former is a typo and should change to .def("reader_listener")

(I don't have a build env setup to test this. Also, probably should have a test case adding to pick this problem up)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugThe PR fixed a bug or issue reported a bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions