Using signal.alarm to terminate a thread

Nick Craig-Wood nick at craig-wood.com
Wed Nov 15 09:30:04 EST 2006


Adrian Casey <adrian.casey at internode.on.net> 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) 
    [GCC 4.1.2 20060715 (prerelease) (Debian 4.1.1-9)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os, pexpect, threading
    >>> def runyes():
    ...     print "Running yes command..."
    ...     pexpect.run('yes', timeout=5)
    ... 
    >>> t = threading.Thread(target=runyes)
    >>> t.start()
    >>> Running yes command...
    t.join()
    >>> 
   

Wheras on Ubuntu/dapper with python-pexpect 0.999-5ubuntu2 I get

    Python 2.4.3 (#2, Apr 27 2006, 14:43:58) 
    [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os, pexpect, threading
    >>> def runyes():
    ...     print "Running yes command..."
    ...     pexpect.run('yes', timeout=5)
    ... 
    >>> t = threading.Thread(target=runyes)
    >>> t.start()
    >>> Running yes command...
    t.join()
    [never returns]

I'd guess at differences between the pexpect versions.  You could try
the pexpect from debian/testing easily enough I expect.

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list