CaliDog / certstream-python

Python library for connecting to CertStream
MIT License
425 stars 72 forks source link

Invoke on_error_handler as described in the docs #64

Open dlenskiSB opened 3 months ago

dlenskiSB commented 3 months ago

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 commented 3 months ago

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)