~free.ekanayaka/storm/any-expr

« back to all changes in this revision

Viewing changes to storm/variables.py

Merge mutable-variables-flush-leak [r=jkakar,jukart]

Remove a leak when mutable variables (ListVariable or PickleVariable instances) are
collected before store.flush, leaving hooks behind them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
550
550
        Variable.__init__(self, *args, **kwargs)
551
551
        if self.event is not None:
552
552
            self.event.hook("start-tracking-changes", self._start_tracking)
553
 
            self.event.hook("object-deleted", self._detect_changes)
 
553
            self.event.hook("object-deleted", self._detect_changes_and_stop)
554
554
 
555
555
    def _start_tracking(self, obj_info, event_system):
556
556
        self._event_system = event_system
564
564
        if (self._checkpoint_state is not Undef and
565
565
            self.get_state() != self._checkpoint_state):
566
566
            self.event.emit("changed", self, None, self._value, False)
 
567
    
 
568
    def _detect_changes_and_stop(self, obj_info):
 
569
        self._detect_changes(obj_info)
 
570
        if self._event_system is not None:
 
571
            self._stop_tracking(obj_info, self._event_system)
567
572
 
568
573
    def get(self, default=None, to_db=False):
569
574
        if self._event_system is not None: