in_retry decorator not threadsafe
adamchainz opened this issue · 5 comments
adamchainz commented
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 commented
Yes, I have a fix for this.
apantel commented
I can either do this as a global map from Thread -> bool, or just leave it off and recommend against nesting in a comment.
timgraham commented
Fixed in cockroachdb/docs#6412.
adamchainz commented
Thanks!