Re: Using signal.alarm to terminate a thread

2006-11-15 Thread Nick Craig-Wood
Adrian Casey <[EMAIL PROTECTED]> wrote: > I'm running Kubuntu 06-06 with python 2.4.3 and the above code runs forever > at 100% cpu utilization. Interesting... I wonder if that is a fixed bug. On Debian/etch with python-pexpect 2.1-1 I get Python 2.4.4c0 (#2, Jul 30 2006, 15:43:58) [G

Re: Using signal.alarm to terminate a thread

2006-11-15 Thread Adrian Casey
Nick Craig-Wood wrote: > Adrian Casey <[EMAIL PROTECTED]> wrote: >> > Adrian Casey <[EMAIL PROTECTED]> wrote: >> > import os, pexpect, threading >> > >> > def runyes(): >> > print "Running yes command..." >> > pexpect.run('yes', timeout=5) >> > >> > t = threading.Thread(target=ru

Re: Using signal.alarm to terminate a thread

2006-11-14 Thread Nick Craig-Wood
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > > The only sensible things you can do from a signal handler is set a > > global flag, or call sem_post on a semaphore, to record the delivery > > of the signal. The remainder of the program can then either poll the > >

Re: Using signal.alarm to terminate a thread

2006-11-14 Thread Fredrik Lundh
Nick Craig-Wood wrote: > The only sensible things you can do from a signal handler is set a > global flag, or call sem_post on a semaphore, to record the delivery > of the signal. The remainder of the program can then either poll the > global flag, or use sem_wait() and sem_trywait() on th

Re: Using signal.alarm to terminate a thread

2006-11-14 Thread Nick Craig-Wood
Adrian Casey <[EMAIL PROTECTED]> wrote: > > Adrian Casey <[EMAIL PROTECTED]> wrote: > > import os, pexpect, threading > > > > def runyes(): > > print "Running yes command..." > > pexpect.run('yes', timeout=5) > > > > t = threading.Thread(target=runyes) > > t.start() > > t.join() >

Re: Using signal.alarm to terminate a thread

2006-11-14 Thread Adrian Casey
Nick Craig-Wood wrote: > Adrian Casey <[EMAIL PROTECTED]> wrote: >> I have a multi-threaded python application which uses pexpect to connect >> to >> multiple systems concurrently. Each thread within my application is a >> connection to a remote system. The problem is when one of the child >

Re: Using signal.alarm to terminate a thread

2006-11-13 Thread Nick Craig-Wood
Adrian Casey <[EMAIL PROTECTED]> wrote: > I have a multi-threaded python application which uses pexpect to connect to > multiple systems concurrently. Each thread within my application is a > connection to a remote system. The problem is when one of the child > threads runs a command which ge

Using signal.alarm to terminate a thread

2006-11-13 Thread Adrian Casey
I have a multi-threaded python application which uses pexpect to connect to multiple systems concurrently. Each thread within my application is a connection to a remote system. The problem is when one of the child threads runs a command which generates an unlimited amount of output. The classic