time-out

Daniel Danger Bentley dbentley at stanford.edu
Tue Feb 3 19:20:10 EST 2004


Hi,

I'm writing a grading script for a class.  Essentially, I wish to iterate
through all the submissions, run them, and grab the output.  HOWEVER, some
of them loop forever, and I want the grading run to (mostly) complete.

So I guess my questions are these:
A) How do I timeout on a read?
B) failing that, how do I have multiple threads and each run wihtout running
into problems with having too many open files?
C) failing that, how do I pause or somehow add handling code so that I don't
clobber everything.

At the moment I have:

while 1:
    try:
        (foo, bar, err) = popen2.popen3('cmd')
    except Exception:
        pass

BUT that leaves me with open files.  But if I try to free them, I get
unbound variable errors.  Surely this has been done before, but I don't see
the (one) obvious way.

Thanks,
Dan





More information about the Python-list mailing list