analytics-python
analytics-python copied to clipboard
return in finally can swallow exceptions
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.
Thank you for this discovery, we are considering solutions.