Trying to use threading.local()

Antoon Pardon antoon.pardon at vub.be
Fri Sep 14 03:25:46 EDT 2018


On 13-09-18 14:29, Chris Angelico wrote:
> "Preferred" doesn't exclude the possibility that alternatives are
> needed, though. For example, good luck making decimal.Decimal contexts
> work correctly without the help of thread-locals - there MIGHT be a
> way to do it, but even if there is, it sure won't be pretty.

Can you elaborate on that. Suppose I have two threads, one in which I need
a precision of 3 and the other in which I need a precision of 7. In what
circumstances is it needed to use threads-locals to accomplish this and
how do I accomplish this?

If I want my decimal code be usable with threads, how should I write it?

-- 
Antoon Pardon




More information about the Python-list mailing list