supporting asyncronous messages

Dan Maas dmaas at
Sun Mar 11 22:01:49 CET 2001

> i'd like to use tristate logic to automatically
> wait for only the relevant events. idea being that if an expression
> evaluates to "unknown", it should block, but if it evaluates to true or
> false it should continue. it means that you only need to worry about
> a single expression to control flow and wait behaviour.

I see what you are trying to do here - basically get "as much work done as
possible" in an environment where input data for a given computation may not
be available immediately. I'm not sure working at the Python syntax level is
the best choice here; there are likely to be many unexpected problems (e.g.
how do you implement coroutines?).

I think a more practical approach would be to write a simple virtual machine
in Python that takes care of scheduling the execution of your coroutines. If
you don't need much flexibility, you could hard-code them or invent a really
simple interpreted language. If you really need full Python, I think you
could do it by breaking the routine up into individual statements. Have the
scheduler try to 'exec' each statement in turn -- if the input isn't ready
yet, throw a special exception. Then the scheduler can record what input was
missing, go take care of some other work, and come back later when the input


More information about the Python-list mailing list