analytics-python icon indicating copy to clipboard operation
analytics-python copied to clipboard

return in finally can swallow exceptions

Open iritkatriel opened this issue 1 year ago • 1 comments

In https://github.com/segmentio/analytics-python/blob/ec1c05ae566d7a32f0b8b5f58752a3fe79319087/segment/analytics/consumer.py#L84 there is a return statement in a finally block, which would swallow any in-flight exception.

This means that if a BaseException (such as KeyboardInterrupt) is raised from the try body, or any exception is raised from an except: clause, it will not propagate on as expected.

See also https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions.

iritkatriel avatar Oct 22 '24 17:10 iritkatriel

Thank you for this discovery, we are considering solutions.

nd4p90x avatar Nov 06 '24 15:11 nd4p90x