#5 expect on multiple children at once (select)


There is a feature of TCL-expect that I really miss on
pexpect: being able to wait on a number of spawn
children within a single command. I guess my way of
better describing it would be by example:

child1 = pexpect.spawn ('ftp site1.org')
child2 = pexpect.spawn ('ftp site2.org')
child3 = pexpect.spawn ('ftp site3.org')

strExpect = 'Name .*: '

result, childMatch = expectSelect( (child1, strExpect), \ (child2, strExpect), \ (child3, strExpect) )

if (!result):
print "timed out on all children"

if (childMatch == 1):
print "matched on child 1"

The main idea of this feature request is that we obtain
a _select_ behavior such that a single execution thread
can continue as soon as the first match (or timeout)
takes place in any of the children in a list provided.

TCL expect allows for that by providing a list of
spawned ids in the -i flag. This is extremely useful
for performance reasons when dealing with multiple
children that are spawned cincurrently.



  • Thomas Kluyver

    Thomas Kluyver - 2014-06-03
    • status: open --> closed
    • Group: --> Next Release (example)
  • Thomas Kluyver

    Thomas Kluyver - 2014-06-03

    This is now being tracked as issue 50 on Github, so I'm closing this copy.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks