def __setattr__(self, name, value): """ Make instance heavier when a new custom attribute is created. """ enter_cs(self) if name not in self.__dict__ and not hasattr(self.__class__, name): self._increase_weight() exit_cs(self) super(PackageElement, self).__setattr__(name, value)
def func(use_cs): for i in xrange(10): if use_cs: enter_cs(d) try: i = shared[0] sleep(.001) shared[0] = i+1 finally: if use_cs: exit_cs(d)
def enter_no_event_section(self): """ Disable all event emission for this object, until `exit_no_event_section` is called. Not also that a "no event section is a critical section for the object (in the sense of the `libadvene.util.synchronized` module). """ enter_cs(self) self.__disabling_count += 1