[Python-Dev] End of the line
Tue, 27 Jul 1999 17:31:13 +0200
> [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.
I think this is exactly what I _didn't_ want:-)
I'd like the delayed read to return an object that will automatically wait
when I try to get the data from it, and the delayed write object to
automatically wait when I garbage-collect it.
Of course, there's no reason why you couldn't also wait on these objects (or,
on unix, pass them to select(), or whatever).
On second thought the method of the delayed read should be called read() in
stead of get(), of course.
Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm