[PEAK] Task containment and isolation
Phillip J. Eby
pje at telecommunity.com
Fri Jul 27 12:23:43 EDT 2007
At 04:51 PM 7/26/2007 -0400, Phillip J. Eby wrote:
>* ``task``, ``Pause``, ``Return``, ``resume()``, and ``TaskCell``
> (support for pseudothreads similar to ``peak.events.Task``)
>...
>* Remove dependency on the unreleased "Contextual" package
> (we're currently only using one exception class from there, and
> the features that will require it in future will be in either the
> "TrellisIO" or "TrellisDB" packages; more details below)
It looks like this isn't quite as easy as I thought. There's a
conflict, in that if I support pseudothreads, I need a way to let
them have different "Contextual" contexts, and prevent pollution
between different contexts. Otherwise, there's no way to create
fully isolated pseudo-threads with their own database connections,
transactions, etc.
There are two things that need to happen. First, when trellis values
are read or changed from outside the trellis, we need to switch the
active context.State to the state owned by the cell(s) in question,
so that any service lookups will find the services associated with that state.
Second, when trellis values are read or changed from inside the
trellis, we need to ensure that the calling rule and the target are
linked to the same context/state. If they aren't, it's an
error. (As a positive side effect, this will also trigger an error
if a cell manages to directly reference a cell that "belongs" to
another thread.)
Unfortunately, this is more overhead than the way things work now,
where we don't check on our callers, and don't keep track of what the
context.State is. We also don't do any dynamic state lookups when
doing cell operations ordinarily; creating a Cell simply captures the
current trellis state, and when the Cells needs this state it just
grabs it from its own attributes.
It also means a dependency on Contextual, and thus coupling between
the two systems. This is somewhat problematic for the short-term
release, since Contextual needs a lot of documentation
work. Probably what I'll do for now is just punt this whole issue
until Contextual is closer to release.
More information about the PEAK
mailing list