[Twisted-Python] Re: hacking on flow
Philippe Lafoucrière
lafou at wanadoo.fr
Thu Apr 10 03:51:28 MDT 2003
Clark, this is just an alogithme I was thinking of, before I found flow.py
I had to manage different flows in one application.
DS1 ----> BLOC1 ---+
|
DS2 ----> BLOC2 ---+---- BLOC3 -----> DS3
is an exemple of what it could be. Every thing is a bloc. DSx are
datasources (there are also blocs). BLOCx are some treatment bloc that
operate with their inputs, and provide the result on their outputs.
this is the algorithm comming with :
all bloc are "inactive"
for bloc in blocs:
if len(bloc.inputs) is 0:
bloc is "active" # it should be a datasource/producer
gotData(bloc, lines) :
for line in lines:
fill in connected blocs's inputs with outputs
connected blocs are active
while connected blocs's inputs are set:
wait # I know, this sucks
bloc is inactive
while there are still active blocs
for bloc in blocs
if all inputs are available (!= None)
bloc.proceed().addCallback(gotData)
# Fin algo #################################
This doesn't work because we wait for blocs to finish their jobs, and never
come back to main loop...
This means also that I have to define a mapping between inputs / outputs of
blocs. I can't see such thing in flow.py, that's maybe why I don't
understand it well.
I wish I was clear enough :p
More information about the Twisted-Python
mailing list