I'm having a problem with PAR in a pipeline of other components. If I
shut down the pipeline with a producerFinished() signal, the PAR
component does not exit. Using a shutdownMicroprocess() signal works OK
though.

By adding liberal quantities of print statements I've worked out that
PAR is hanging in the pause loop near the end of main():

          # If there's nothing to do, then sleep
          while not self.anyReady() and not shutdown:
              self.pause()
              yield 1

When each child component exits, PAR is woken up but, as there's no
input it instantly pauses again. A solution I've found is to put a
childrenDone() test in the loop:

          # If there's nothing to do, then sleep
          while not self.anyReady() and not shutdown:
              if self.childrenDone():
                  shutdown = True
              else:
                  self.pause()
              yield 1

This appears to work, but there may be subtleties in PAR's design I
haven't considered.

A further simplification is to remove the shutdown variable entirely,
using break to exit the main loop wherever shutdown would have been set.
The sleeping inner loop then becomes:

          # If there's nothing to do, then sleep
          while not self.anyReady() and not self.childrenDone():
              self.pause()
              yield 1

This has the small disadvantage that childrenDone() is called once more
often than necessary before the main loop is exited.

(As an aside, I'm not a fan of having loops within loops like this. I
like my components to have a simple main loop with an if ... elif ...
elif ... else self.pause() chain.)
-- 
Jim Easterbrook
Senior Research Engineer

BBC Research & Development South Lab
BBC Centre House
56 Wood Lane
London W12 7SB

Phone:  +44 303 040 9705
Mobile: +44 7590 307002
FAX:    +44 20 8811 8815

-- 
You received this message because you are subscribed to the Google Groups 
"kamaelia" group.
To post to this group, send email to kamae...@googlegroups.com.
To unsubscribe from this group, send email to 
kamaelia+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/kamaelia?hl=en.

Reply via email to