cockroachdb/django-cockroachdb

in_retry decorator not threadsafe

adamchainz opened this issue · 5 comments

The in_retry example on the tutorial uses a global variable in_retry. This won't work when deployed under a threaded WSGI server, since the variable will be shared between threads. contextvars are the newest Python solution to this problem, but probably a bigger rewrite to a loop or recursion would be better.

@apantel can you take a look at this?

Yes, I have a fix for this.

I can either do this as a global map from Thread -> bool, or just leave it off and recommend against nesting in a comment.

Thanks!