question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python Pulsar client appears to throw regular `Exception`s instead of `PulsarException`s

See original GitHub issue

Expected behavior

The Python client should throw a subclass of Exception, not just Exception.

Actual behavior

An Exception is thrown. See, for example:

In [2]: p = pulsar.Client()

In [3]: c = p.get_consumer("foo")
2018-12-04 17:24:48.860 INFO  ConnectionPool:63 | Created connection for pulsar://localhost:6650
2018-12-04 17:24:48.871 ERROR ClientConnection:329 | [<none> -> pulsar://localhost:6650] Failed to establish connection: Connection refused
2018-12-04 17:24:48.872 INFO  ClientConnection:1237 | [<none> -> pulsar://localhost:6650] Connection closed
2018-12-04 17:24:48.872 ERROR ClientImpl:374 | Error Checking/Getting Partition Metadata while Subscribing- 5
2018-12-04 17:24:48.872 INFO  ClientConnection:195 | [<none> -> pulsar://localhost:6650] Destroyed connection

< deleted internal wrapper code >

Exception: Pulsar error: ConnectError

To demonstrate it’s not a subclass:

In [8]: try:
   ...:     c.receive(timeout_millis=500)
   ...: except Exception as e:
   ...:     print(type(e))
   ...:
<class 'Exception'>

Steps to reproduce

Easiest way is probably supply a bogus URL to get a ConnectError

System configuration

Pulsar version: 2.2.0 for both Pulsar and the Python client

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
legendtklcommented, Dec 7, 2018

I would like to work on this issue

2reactions
merlimatcommented, Dec 8, 2018

@legendtkl ideally the exception should be wrapped in a PulsarException, so that application can catch a specific exception instead of a blanket catch. Also, for example when getting a timeout, one should be able to check the type of the exception

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Pulsar client appears to throw regular Exceptions ...
grantwwu opened a new issue #3127: Python Pulsar client appears to throw regular Exceptions instead of Pulsar Exceptions URL: ...
Read more >
Pulsar Python client
Pulsar Python client library is a wrapper over the existing C++ client library and exposes all of the same features. You can find...
Read more >
API Documentation - Apache Pulsar
The Pulsar Python client library is based on the existing C++ client library. ... PartitionsRoutingMode, BatchingType # noqa: F401 from pulsar.exceptions ...
Read more >
Pulsar Python client
If the format of the topic schema is incompatible with the schema definition, an exception occurs in the producer creation. Once a producer...
Read more >
The Pulsar Python client
The Pulsar Python client library is a wrapper over the existing C++ client ... If there is a mismatch, the producer creation will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found