Author schmir
Recipients jvd66, schmir
Date 2007-10-26.09:47:55
SpamBayes Score 0.116469
Marked as misclassified No
Message-id <1193392077.67.0.368951692998.issue1089358@psf.upfronthosting.co.za>
In-reply-to
Content
PyOS_setsig in pythonrun.c now calls siginterrupt(sig, 1) (in Python
2.4.4/Python 2.5.1, but not in Python 2.3). So you should be able to
timeout the system calls with a signal.alarm call.

However, having siginterrupt available would still be useful.
I have some patches for the signal module and will clean them up in some
days and attach to this bug.

Here's an implementation using ctypes:

def siginterrupt(signum, flag):
    """change restart behavior when a function is interrupted by the 
    specified signal. see man siginterrupt.
    """
    import ctypes
    import sys
    
    if flag:
        flag = 1
    else:
        flag = 0
        
    if sys.platform=='darwin':
        libc = ctypes.CDLL("libc.dylib")
    elif sys.platform=='linux2':
        libc = ctypes.CDLL("libc.so.6")
    else:
        libc = ctypes.CDLL("libc.so")

    if libc.siginterrupt(signum, flag)!=0:
        raise OSError("siginterrupt failed")
History
Date User Action Args
2007-10-26 09:47:57schmirsetspambayes_score: 0.116469 -> 0.116469
recipients: + schmir, jvd66
2007-10-26 09:47:57schmirsetspambayes_score: 0.116469 -> 0.116469
messageid: <1193392077.67.0.368951692998.issue1089358@psf.upfronthosting.co.za>
2007-10-26 09:47:57schmirlinkissue1089358 messages
2007-10-26 09:47:56schmircreate