[PEAK] A few issues and suggestions

Sergey Schetinin maluke at gmail.com
Mon Nov 3 16:08:46 EST 2008


1. A small change to circularity detection to make errors easier to interpret

In Controller._retry:

                if item in self.routes:
                    path = find_circularity(item, self.routes, item, {})
                    if path:
                        raise CircularityError(path)


def find_circularity(item, routes, start, seen):
    for via in routes.get(item, ()):
        if via is start:
            return (via,)
        elif via not in seen:
            seen[via] = 1
            path = find_circularity(via, routes, start, seen)
            if path is not None:
                return path + (via,)


2. I had an issue when there's no circularity, but no valid evaluation
order either. The rules weren't conflicting, but depending on order
rules ran the dependency tree was different, so the retry was an
infinite loop, cycling through a set of different possible rule
evaluation orders. This is a rare case, and I cannot immediately write
a test to reproduce it. It can be detected: if a certain order of
scheduled rules was already tried in this transaction, that means we
are in infinite loop. But this detection is rarely needed and would be
relatively costly, so if ever implemented, I think should not kick in
until there was a fair number of retries in a single transaction,
which would indicate we are possibly in an infinite loop.

Why I'm mentioning this is because I didn't think this case was
possible, but I do see it consistently in one big test app, which
would be quite hard to strip down to make it a test case. Maybe you'll
have better luck constructing a small set of rules to reproduce it,
but I'll try it again in a few days anyway.

3. Assigning Cell instances to CellAttributes.
When you set a component attribute to a cell (for ex. c.val = Cell())
it's treated as a special case and overwrites the cell in __cells__
dictionary. I suppose this is done to simplify use of existing cells
in component initialization, but there seem to be no other use for it.
However it's useful sometimes to have a cell as a value of another
cell, so it would be nice if it this special case was implemented in
Component.__init__ instead of CellAttribute.__set__

4. Also related, new @compute rules being settable, which I mentioned
in http://www.eby-sarna.com/pipermail/peak/2008-October/003116.html
There's a special case to support that, but that doesn't make any
sense to me. What is it for?



More information about the PEAK mailing list