-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adds add_callback/add_errback example to docs #1441
Conversation
Thanks so much for working on this!! I am on vacation with phone only for
the rest of this week but i will take a look early next week when i return.
…On Mar 13, 2018 6:36 PM, "Berkodev" ***@***.***> wrote:
After spending quite some time figuring out how to properly add
callbacks/errbacks to the producer.send future obj, decided to add a basic
example to the docs (Issue #1256
<#1256> ).
I didn't really know where to put it as there seemed to be no examples in
the docs outside of "Usage Overview", so I just put it there.
I am willing to expand upon this if needed, but I'll need to know where
exactly to put it in and some guidance as to what you want to see in terms
of explanation/example.
Have a good day!
------------------------------
You can view, comment on, or merge this pull request online at:
#1441
Commit Summary
- Adds add_callback/add_errback example to docs
File Changes
- *M* docs/usage.rst
<https://github.com/dpkp/kafka-python/pull/1441/files#diff-0> (12)
Patch Links:
- https://github.com/dpkp/kafka-python/pull/1441.patch
- https://github.com/dpkp/kafka-python/pull/1441.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1441>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAzetBBF5LKcJlE2wNEDg-rBaI4HPnLWks5teAOEgaJpZM4SpI60>
.
|
No worries, I'm actually on a vacation myself next week, so will be available the following week if needed. Enjoy the rest of your vacation! |
docs/usage.rst
Outdated
print(record_metadata.offset) | ||
|
||
def on_send_error(excp): | ||
log.exception() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just doublechecking, since I'm not sure how this works:
Is the send exception always going to be the most recent one raised? If you screwed up your callback somehow and threw an exception, it would hide the send exception.
Perhaps it'd be better to illustrate how to pass the excp
into log.error()
? This is honestly less of a kafka-python
thing, and more just showing clearly how python logging works, as we often get questions on the issue tracker about that as well...
Just a thought, I do not have a strong opinion, and I am not even 100% sure how this works in this particular example as I haven't played with it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree -- log.exception()
may not always work here because we don't guarantee that the errback is evaluated within the context of a exception handler. It would be better to pass the exception explicitly:
def on_send_error(excp):
log.error('I am an errback', exc_info=excp)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes re: log.exception / log.error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I was trying to use the same expressions used in the file (line 71) for the sake of standard, but I can see how that would be an issue in an async context.
Thanks! |
After spending quite some time figuring out how to properly add callbacks/errbacks to the producer.send future obj, decided to add a basic example to the docs (Issue #1256 ).
I didn't really know where to put it as there seemed to be no examples in the docs outside of "Usage Overview", so I just put it there.
I am willing to expand upon this if needed, but I'll need to know where exactly to put it in and some guidance as to what you want to see in terms of explanation/example.
Have a good day!