channable / opnieuw

One weird trick to make your code more reliable
https://tech.channable.com/posts/2020-02-05-opnieuw.html
BSD 3-Clause "New" or "Revised" License
289 stars 11 forks source link

Prevent retry state namespaces leak across context #15

Closed LeonardBesson closed 2 years ago

LeonardBesson commented 2 years ago

Currently, the retry state namespaces leak between asyncio tasks or threads. This is important in concurrent code where the retry states should not affect others. For example it might make sense to disable retries under certain conditions (I also added an utility for this)

This PR adds contexvars when usable (>= 3.7) which prevent these leaks.

LeonardBesson commented 2 years ago

@jochemb I think all comments are addressed, and I've added a test for the nested case.

LeonardBesson commented 2 years ago

@OpsBotPrime merge

OpsBotPrime commented 2 years ago

Pull request approved for merge by @LeonardBesson, rebasing now.

OpsBotPrime commented 2 years ago

Rebased as 995f0400405f9f1b39320f2f751da780527ee059, waiting for CI …