Do you mean that now it is not safe to use evaluate=True in one thread and evaluate=False in another?
On Saturday, August 1, 2020 at 10:40:19 PM UTC+3, Oscar wrote: > > On Sat, 1 Aug 2020 at 18:40, Paul Royik <[email protected] <javascript:>> > wrote: > > > > In sympy.core.parameters it is written that "WARNING! Although the > global parameters are thread-local, SymPy's cache is not by now. This may > lead to undesired result in multi-threading operations." > > But in code I see > > > > def __setattr__(self, name, value): > > if getattr(self, name) != value: > > clear_cache() > > return super().__setattr__(name, value) > > > > > > So, does this workaround help to use this feature safely? > > It possibly helps but it isn't really thread-safe. The problem is that > there isn't a single cache, there are many little caches and clearing > them all can take some time and is not atomic. If you have two threads > using the same cache but with different settings for the global > parameters then one thread might insert items into the cache while > another is clearing the cache. By the time clear_cache finishes the > cache might not actually be empty. > > To make the cache properly thread-safe in a situation where threads > can independently alter the global parameters there needs to be a > separate cache for each thread. > > Personally I think that the ultimate fix is the elimination of all > global parameters. That's not easy but it's what we should aim for. > > -- > Oscar > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/dfa5f115-1f43-41c0-9451-94760e5ca40eo%40googlegroups.com.
