Show
Ignore:
Timestamp:
04/10/04 00:24:47 (20 years ago)
Author:
jalet
Message:

Began work on correct handling of child processes when jobs are cancelled by
the user. Especially important when an external requester is running for a
long time.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r1411 r1433  
    2424# 
    2525# $Log$ 
     26# Revision 1.38  2004/04/09 22:24:46  jalet 
     27# Began work on correct handling of child processes when jobs are cancelled by 
     28# the user. Especially important when an external requester is running for a 
     29# long time. 
     30# 
    2631# Revision 1.37  2004/03/18 19:11:25  jalet 
    2732# Fix for raw jobs in cupspykota 
     
    190195class PyKotaBackend(PyKotaFilterOrBackend) :         
    191196    """A class for the pykota backend.""" 
    192     def __init__(self) : 
    193         """Does normal initialization then installs signal handler.""" 
    194         # Normal init 
    195         PyKotaFilterOrBackend.__init__(self) 
    196          
    197         # then deal with signals 
    198         # CUPS backends ignore SIGPIPE and exit(1) on SIGTERM 
    199         # Fortunately SIGPIPE is already ignored by Python 
    200         # It's there just in case this changes in the future. 
    201         # Here we have to handle SIGTERM correctly, and pass 
    202         # it to the original backend if needed. 
    203         self.gotSigTerm = 0 
    204         signal.signal(signal.SIGPIPE, signal.SIG_IGN) 
    205         signal.signal(signal.SIGTERM, self.sigterm_handler) 
    206          
    207     def sigterm_handler(self, signum, frame) : 
    208         """Sets a global variable whenever SIGTERM is received.""" 
    209         # SIGTERM will be ignore most of the time, but during 
    210         # the call to the real backend, we have to pass it through. 
    211         self.gotSigTerm = 1 
    212         self.logger.log_message(_("SIGTERM received, job %s cancelled.") % self.jobid, "info") 
    213          
    214197    def acceptJob(self) :         
    215198        """Returns the appropriate exit code to tell CUPS all is OK."""