[PEAK] Re: trellis.Set.discard

Sergey Schetinin maluke at gmail.com
Sat Oct 11 15:06:11 EDT 2008


On Sat, Oct 11, 2008 at 18:59, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 04:04 AM 10/11/2008 +0300, Sergey Schetinin wrote:
>>
>> I've noticed that set.discard both reads and writes the set so
>> Set.discard should raise an exception.
>
> Eh?  It doesn't read and write the set, it performs an idempotent operation
> on the set.  To be a read, it would have to communicate information *out* of
> the method.

That's right, I just got confused for a moment.


> Congratulations; you just found a way to violate causality in a task.  :)
>
> What I don't understand is why this works when it's NOT in a task.  That is,
> if you change TaskCell to @trellis.atomically and take out the yield, it
> does what we expect it to.
>
> The discard operation uses to_add, which sets up a savepoint at a time when
> .v is false.  Later, when .v is true, the add operation adds to to_add.
>  This second operation is also critical, because if you don't do the add, no
> rollback occurs.
>
> Clearly, there is some reason why the second execution of the maintain rule
> is being rolled back, which then forces a rollback all the way to the first
> execution of the rule.
>
> This would seem to imply that there is something dreadfully wrong with using
> these sorts of savepoints in "futures"; it is a flaw that they are allowed
> to rollback to the middle of a rule's execution.  They *should* be required
> to roll back all the way to the beginning of the rule, or something of that
> sort.
>
> But I am still baffled as to why this only seems to be triggered in the task
> case.

I was investigating exactly what is happening and stumbled over
something odd. When I add some debug prints, the version with
@atomically starts to print "False" as well. The minimal change to
trigger this is to add str(self.queues) to Controller.schedule in
stm.py. I imagine there's something in Cell.__repr__ that changes the
behavior, but don't yet understand what is it. It doesn't seem to
force the rule to run or anything like that.




-- 
Best Regards,
Sergey Schetinin

http://s3bk.com/ -- S3 Backup
http://word-to-html.com/ -- Word to HTML Converter



More information about the PEAK mailing list