-
Notifications
You must be signed in to change notification settings - Fork 220
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
Instantiate error for each future.set_exception #247
Instantiate error for each future.set_exception #247
Conversation
Sorry for the long wait on this, still checking if there's a more general way of fixing it. |
@tvoinarovskyi Have you found something? I was trying to find this bug directly in Python but with no success. This issue is a time bomb for us because it can effectively kill one of our service. What if we use |
@tvoinarovskyi I added the version with copy. Now it could be ready to merge if you agrees. |
future.set_exception(exception) | ||
# we need to copy exception so traceback is not multiplied | ||
# https://github.com/aio-libs/aiokafka/issues/246 | ||
future.set_exception(copy.deepcopy(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.
Seems like copy.copy() is enough to prevent traceback changes. The tracebacks are immutable and linked in a linked list, so copy is enough.
For example:
import copy
def test_raise_many():
err = ValueError()
for i in range(100):
try:
raise copy.copy(err)
except Exception:
pass
raise err
test_raise_many()
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.
See https://gitter.im/aio-libs/Lobby?at=5a0d094871ad3f8736edbd5b reply on gitter also
Sorry, was away for some time. Please use copy and lets merge it. |
9160162
to
a97d6a5
Compare
@tvoinarovskyi Done. Thanks for investigation. |
This fixes #246 . I've found that
set_exceptions
is used also inMessageBatch.failure()
but it is settings an exception that is passed as argument. I would need to change it's interface to pass some function that returns the exception so it can be called for every future inMessageBatch._msg_future
. Do you agree or do you have another idea?