Re: A few issues and suggestions
"Sergey Schetinin" <[email protected]>
| Newsgroups | gmane.comp.python.peak |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Nov 5, 2008 at 18:58, Phillip J. Eby <pje-Wh6+Hckhi6HFNGf7iClzIwC/[email protected]> wrote: > At 04:37 PM 11/5/2008 +0200, Sergey Schetinin wrote: >> >> One more issue: >> >> File "c:\files\checkouts\trellis\peak\events\stm.py", line 470, in >> atomically >> return super(Controller,self).atomically(self._process, func, args, kw) >> File "c:\files\checkouts\trellis\peak\events\stm.py", line 186, in >> atomically >> self.cleanup(*sys.exc_info()) >> File "c:\files\checkouts\trellis\peak\events\stm.py", line 182, in >> atomically >> retval = func(*args, **kw) >> File "c:\files\checkouts\trellis\peak\events\stm.py", line 486, in >> _process >> self.run_rule(listener) >> File "c:\files\checkouts\trellis\peak\events\stm.py", line 364, in >> run_rule >> listener.run() >> File "c:\files\checkouts\trellis\peak\events\trellis.py", line 559, in >> run >> raise AssertionError("This should never happen!", self) >> AssertionError: ('This should never happen!', Cell(<bound method >> VPanel._minh of <gui5.models.VPanel object at 0x00C8CBB0>>, 0)) >> >> >> >> And the rule for which that happens looks like this: >> >> @maintain(initially=0) >> def _minh(self): >> prev = self._minh >> if prev == 0 and self.live: >> return self.height >> return prev > > Unfortunately, the rule itself will give us no clue of what happened. > Basically, it looks like for this to have happened, the cell had to have > been assigned to between the time it was scheduled, and the time it was run. > I suspect it could be triggered by a sequence like: > > cell A depends on B and C > B depends on C > C triggers a change in B > B sets a value in A > > Probably, setting a value should cancel the scheduled rule if it doesn't > need initialization. I suggest adding an "else: cancel(self)" to the "if > self._needs_init:" block in Cell.set_value. If that makes the problem go > away, the above hypotheses are probably correct. I've encountered this issue again, this time I have a better idea of what's happening and it seems to be exactly the case: assigning to cell that was already scheduled. I tried the suggested fix and it does work perfectly. I also see that I managed to apply it to the wrong function last time, so the earlier report that it didn't work was invalid. Here's a test case based on your description: from peak.events import trellis def A(): B.value C.value A = trellis.Cell(A, None) @trellis.Cell def B(): A.value = C.value C = trellis.Value() A.value C.value = 1