channable / opnieuw

One weird trick to make your code more reliable

Home Page:https://tech.channable.com/posts/2020-02-05-opnieuw.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for python 3.11 Exception Groups

p-nilsson opened this issue · comments

Opnieuw will only raise the last occurred exception to the user. This means, you can potentially do an HTTP request, get a bad request error, retry, get a rate limit error, and then you only get to see the rate limit error, while you likely want to fix the cause of the bad request error. Python 3.11 introduced Exception groups. This gives us the opportunity to raise all the exceptions from all tries to allow the users of opnieuw to do better error handling and get more details about what is actually going wrong.

This will likely be a breaking change unless we want to take time and effort into making it backwards compatible somehow

Reading the PEP seems to imply that there is no way to offer this in a backwards compatible way:
Backwards Compatibility.

This is because an except that relies on catching T should now become except* T. Although I don't think we catch errors out of opnieuw very often it does seem that the best way would be a retry_with_group, or a use_exception_group flag that we can turn on if desired.

I think there really is no need for this now we have implemented #22.

Let's close for now.