Show
Ignore:
Timestamp:
01/16/06 23:27:07 (19 years ago)
Author:
jerome
Message:

Now cupspykota can be interrupted cleanly with SIGINT.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2622 r2624  
    5959        PyKotaTool.deferredInit(self) 
    6060        self.gotSigTerm = 0 
     61        self.disableSigInt() 
    6162        self.installSigTermHandler() 
    6263         
     
    7879        signal.signal(signal.SIGTERM, self.sigtermHandler) 
    7980        self.logdebug("SIGTERM handler installed.") 
     81         
     82    def disableSigInt(self) :     
     83        """Disables the SIGINT signal (which raises KeyboardInterrupt).""" 
     84        self.logdebug("Disabling SIGINT...") 
     85        self.oldSigIntHandler = signal.signal(signal.SIGINT, signal.SIG_IGN) 
     86        self.logdebug("SIGINT disabled.") 
     87         
     88    def enableSigInt(self) :     
     89        """Enables the SIGINT signal (which raises KeyboardInterrupt).""" 
     90        self.logdebug("Enabling SIGINT...") 
     91        signal.signal(signal.SIGINT, self.oldSigIntHandler) 
     92        self.logdebug("SIGINT enabled.") 
    8093         
    8194    def discoverOtherBackends(self) :     
     
    238251        self.logdebug("JobOriginatingHostName : %s" % self.ClientHost) 
    239252         
     253        self.enableSigInt() 
    240254        self.logdebug("Backend initialized.") 
    241255         
     
    11541168            wrapper.exportJobInfo() # re-exports in case it was overwritten 
    11551169            retcode = wrapper.mainWork() 
     1170        except KeyboardInterrupt :     
     1171            wrapper.printInfo(_("Job %s interrupted by the administrator !") % wrapper.JobId, "warn") 
     1172            retcode = 0 
    11561173        except SystemExit, e :     
    11571174            retcode = e.code