On Tue, Nov 09, 2010 at 03:01:09PM -0500, Tres Seaver wrote:
I think the is a possible threading issue with Element.setTaggedValue and Specification.subscribe - if two threads called the method concurrently, then one of the values might be lost. I think the correct way to do it would be:
tv = self.__tagged_values if tv is None: tv = self.__dict__.setdefault('_Element__tagged_values', {}) tv[tag] = value
This does bring the name mangling back though.
Thanks, I fixed the threading issue in Specification.subscribe. Given that that part of subscribe is not run very often, I think we can live with limited name mangling.
I'm pretty sure we can safely neglect threading issues here: no sane code will call 'setTaggedValue' except at import time, when we should be serialized by Python's own import lock.
Great, I quoted you on that ;) The setdefault fix for the threading issue is not compatible with the use of __slots__. I couldn't find another way to do it. -- Brian Sutherland