[Python-Dev] End of the line
Mark Hammond
mhammond@skippinet.com.au
Wed, 28 Jul 1999 00:45:12 +1000
[Jack seems to like an asynch IO model]
> def foo():
> obj = stdin.delayed_read()
> obj2 = stdout.delayed_write("data")
> do_lengthy_computation()
> data = obj.get() # Here we wait for the read to complete
> del obj2 # Here we wait for the write to
> complete.
>
> This gives a fairly nice programming model.
Indeed. Taking this a little further, I come up with something like:
inlock = threading.Lock()
buffer = stdin.delayed_read(inlock)
outlock = threading.Lock()
stdout.delayed_write(outlock, "The data")
fired = threading.Wait(inlock, outlock) # new fn :-)
if fired is inlock: # etc.
The idea is we can make everything wait on a single lock abstraction.
threading.Wait() could accept lock objects, thread objects, Sockets, etc.
Obviously a bit to work out, but it does make an appealing model. OTOH, I
wonder how it fits with continutations etc. Not too badly from my weak
understanding. May be an interesting convergence!
Mark.