SourceForge has been redesigned. Learn more.
Close

Catching SIGINT

Help
IcedSt
2012-10-24
2013-04-04
  • IcedSt

    IcedSt - 2012-10-24

    Before using pydoop i was able to do a signal.singal(SIGINT, signalhandlerfunc) in my code without a hitch.

    I now have to reset the SIGINT handler again after i call hadut.PipesRunner(prefix=PREFIX, logger=logger).

    Why? 

    Is this a bug or a known feature?

     
  • IcedSt

    IcedSt - 2012-10-24

    I am using pydoop 0.64

     
  • Simone Leo

    Simone Leo - 2012-10-25

    Hello,

    we've done signal capturing in our own projects for a while. Pydoop code does not interfere with signal handling, so my guess is that something has changed in the underlying code. Right now I don't have the time to investigate on this - I'll keep you informed. In the meantime, a code snippet that shows how you trigger the problem would be helpful.

    Simone

     
  • IcedSt

    IcedSt - 2013-03-22

    I'm not sure what to give for now, except for this snippet. Let me know if you want something else(I've moved on from this portion of the script but been wanting to answer for a long time now)

        signal.signal(signal.SIGINT,    self.cleanupFunc)
        signal.signal(signal.SIGHUP,    self.cleanupFunc)
        signal.signal(signal.SIGTERM,   self.cleanupFunc)
        signal.signal(signal.SIGUSR1,   self.cleanupFunc)
    
        ...
        ...
        ...
        ...
    
        ...
    
        try:
            runner          = hadut.PipesRunner(prefix=PREFIX, logger=loggingThing)
        except Exception as e:
            loggingthingLog.critical(e)
            sys.exit(1)
    
        # placed here AGAIN.. b/c of the code above removes it somehow...
        # Need to place a bug @ the pydoop sf site
        signal.signal(signal.SIGINT, self.cleanupFunc)
    
     
  • Simone Leo

    Simone Leo - 2013-04-04

    Hello,

    I could not reproduce your bug. Here is what I'm running on my machine:

    import signal
    import pydoop.hadut as hadut
    
    def cleanupFunc(signum, frame):
      pass
    
    print repr(signal.getsignal(signal.SIGINT))
    signal.signal(signal.SIGINT, cleanupFunc)
    print repr(signal.getsignal(signal.SIGINT))
    runner = hadut.PipesRunner(prefix="FOO", logger=None)
    print repr(signal.getsignal(signal.SIGINT))
    

    The output (Pydoop 0.9.1, CDH 4.2.0) is:

    <built-in function default_int_handler>
    <function cleanupFunc at 0x7f4ff070d488>
    <function cleanupFunc at 0x7f4ff070d488>
    

    Can you try running this snippet on your system? Are you sure that the handler for SIGINT does not change before you create the runner object?

    Simone

     

Log in to post a comment.