Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke on_error_handler as described in the docs #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dlenskiSB
Copy link

According to the example in the README, the on_error handler should be called with two parameters, of which the first is the CertStreamClient instance:

def on_error(instance, exception):
# Instance is the CertStreamClient instance that barfed
print("Exception in CertStreamClient! -> {}".format(exception))

According to the example in the README, the `on_error` handler should be
called with two parameters, of which the first is the `CertStreamClient`
instance:

https://github.com/CaliDog/certstream-python/blob/97eb5b37e2c2077495e20d6df3459088a5262b48/README.md?plain=1#L61-L63
@dlenskiSB
Copy link
Author

dlenskiSB commented Jun 13, 2024

In addition to aligning the docs with the code, this fix is needed to be able to construct a CertStreamClient object with an error handler that actually has access to the instance object.

Currently, I have to do this by modifying the .on_error_handler after construction:

from functools import partial

def on_error_handler(instance, exc):
    # ...

# FIXME: Docs say instance is passed as first param, but it isn't
c = CertStreamClient(callback, url='wss://certstream.calidog.io/', skip_heartbeats=True)
c.on_error_handler = partial(on_error_handler, c)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant