Fix incorrect logs when a message failed to be decoded with the writer schema (#200)

### Motivation


When `self._decode_bytes(, writer_schema)` failed, the error
log is still `Failed to get schema info`, which is confusing.

### Modifications

Modify the error message. Even if it failed at
`self._get_writer_schema(topic, version)`, there would still be error
logs from the C++ client.
1 file changed
tree: d020bc99b28afe51e2808f9b1fcac4cf6f552033
  1. .github/
  2. build-support/
  3. cmake_modules/
  4. examples/
  5. pkg/
  6. pulsar/
  7. src/
  8. tests/
  9. .asf.yaml
  10. .clang-format
  11. .gitignore
  12. .gitmodules
  13. CMakeLists.txt
  15. dependencies.yaml
  17. NOTICE

Pulsar Python client library

Pulsar Python clients support a variety of Pulsar features to enable building applications connecting to your Pulsar cluster. For the supported Pulsar features, see Client Feature Matrix.


PyBind11 is a header-only library and a submodule, so you can simply download the submodule so that CMake can find this dependency.

git submodule update --init

You can also download the pybind11 directly like:

pip3 install pyyaml
export PYBIND11_VERSION=$(./build-support/ pybind11)
curl -L -O${PYBIND11_VERSION}.tar.gz
tar zxf v${PYBIND11_VERSION}.tar.gz
mv pybind11-${PYBIND11_VERSION} pybind11

After that, you only need to install the Pulsar C++ client dependency into the system path. You can install the pre-built binaries or build from source.

Install the Python wheel

Make sure the PyBind11 submodule has been downloaded and the Pulsar C++ client has been installed. Then run the following commands:

cmake -B build
cmake --build build
cmake --install build
python3 ./ bdist_wheel
python3 -m pip install dist/pulsar_client-*.whl --force-reinstall


  1. The separate build directory is created to store all CMake temporary files. However, the requires the to be under the project directory.
  2. Add the --force-reinstall option to overwrite the existing Python wheel in case your system has already installed a wheel before.
  3. On Windows, the Python command is py instead of python3.

Running examples

You can run python3 -c 'import pulsar' to see whether the wheel has been installed successfully. If it fails, check whether dependencies (e.g., are in the system path. If not, make sure the dependencies are in LD_LIBRARY_PATH (on Linux) or DYLD_LIBRARY_PATH (on macOS).

Then you can run examples as a simple end-to-end test.

# In terminal 1
python3 ./examples/
# In terminal 2
python3 ./examples/

Before executing the commands above, you must ensure the Pulsar service is running. See here for quick start.

Unit tests

Before running the unit tests, you must run a Pulsar service with all things set up:


The command above runs a Pulsar standalone in a Docker container. You can run ./build-support/ to stop it.

Run all unit tests:


Run a single unit test (e.g., PulsarTest.test_tls_auth):

python3 ./tests/ 'PulsarTest.test_tls_auth'

Generate API docs

Pulsar Python Client uses pydoctor to generate API docs. To generate by yourself, you need to install the Python library first. Then run the following command in the root path of this repository:

sudo python3 -m pip install pydoctor
cp $(python3 -c 'import _pulsar, os; print(_pulsar.__file__)') ./
pydoctor --make-html \
  --docformat=numpy --theme=readthedocs \
  --intersphinx= \
  --html-output=<path-to-apidocs> \
  --introspect-c-modules \
  ./ \

Then the index page will be generated in <path-to-apidocs>/index.html.


We welcome contributions from the open source community!

If your contribution adds Pulsar features for Python clients, you need to update both the Pulsar docs and the Client Feature Matrix. See Contribution Guide for more details.