Index: /pykota/trunk/pykota/requesters/snmp.py
===================================================================
--- /pykota/trunk/pykota/requesters/snmp.py (revision 1257)
+++ /pykota/trunk/pykota/requesters/snmp.py (revision 1433)
@@ -22,4 +22,9 @@
 #
 # $Log$
+# Revision 1.14  2004/04/09 22:24:47  jalet
+# 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.
+#
 # Revision 1.13  2004/01/08 14:10:33  jalet
 # Copyright year changed.
@@ -76,6 +81,7 @@
 class Requester :
     """A class to send queries to printers via SNMP."""
-    def __init__(self, printername, arguments) :
+    def __init__(self, kotabackend, printername, arguments) :
         """Sets instance vars depending on the current printer."""
+        self.kotabackend = kotabackend
         self.printername = printername
         args = [x.strip() for x in arguments.split(',')]
Index: /pykota/trunk/pykota/requesters/external.py
===================================================================
--- /pykota/trunk/pykota/requesters/external.py (revision 1257)
+++ /pykota/trunk/pykota/requesters/external.py (revision 1433)
@@ -22,4 +22,9 @@
 #
 # $Log$
+# Revision 1.11  2004/04/09 22:24:47  jalet
+# 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.
+#
 # Revision 1.10  2004/01/08 14:10:33  jalet
 # Copyright year changed.
@@ -63,6 +68,7 @@
 class Requester :
     """A class to send queries to printers via external commands."""
-    def __init__(self, printername, arguments) :
+    def __init__(self, kotabackend, printername, arguments) :
         """Sets instance vars depending on the current printer."""
+        self.kotabackend = kotabackend
         self.printername = printername
         self.commandline = arguments.strip()
Index: /pykota/trunk/pykota/tool.py
===================================================================
--- /pykota/trunk/pykota/tool.py (revision 1426)
+++ /pykota/trunk/pykota/tool.py (revision 1433)
@@ -22,4 +22,9 @@
 #
 # $Log$
+# Revision 1.81  2004/04/09 22:24:47  jalet
+# 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.
+#
 # Revision 1.80  2004/04/06 12:00:21  jalet
 # uninitialized values caused problems
@@ -741,4 +746,21 @@
         self.exportJobInfo()
         
+        # then deal with signals
+        # CUPS backends ignore SIGPIPE and exit(1) on SIGTERM
+        # Fortunately SIGPIPE is already ignored by Python
+        # It's there just in case this changes in the future.
+        # Here we have to handle SIGTERM correctly, and pass
+        # it to any child if needed.
+        self.gotSigTerm = 0
+        signal.signal(signal.SIGPIPE, signal.SIG_IGN)
+        signal.signal(signal.SIGTERM, self.sigterm_handler)
+        
+    def sigterm_handler(self, signum, frame) :
+        """Sets a global variable whenever SIGTERM is received."""
+        # SIGTERM will be ignore most of the time, but during
+        # the call to the real backend, we have to pass it through.
+        self.gotSigTerm = 1
+        self.logger.log_message(_("SIGTERM received, job %s cancelled.") % self.jobid, "info")
+        
     def exportJobInfo(self) :    
         """Exports job information to the environment."""
Index: /pykota/trunk/pykota/accounters/querying.py
===================================================================
--- /pykota/trunk/pykota/accounters/querying.py (revision 1271)
+++ /pykota/trunk/pykota/accounters/querying.py (revision 1433)
@@ -22,4 +22,9 @@
 #
 # $Log$
+# Revision 1.13  2004/04/09 22:24:47  jalet
+# 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.
+#
 # Revision 1.12  2004/01/11 23:22:42  jalet
 # Major code refactoring, it's way cleaner, and now allows automated addition
@@ -72,5 +77,5 @@
         """Initializes querying accounter."""
         AccounterBase.__init__(self, kotabackend, arguments)
-        self.requester = openRequester(kotabackend.config, kotabackend.printername)
+        self.requester = openRequester(kotabackend, kotabackend.printername)
         self.isDelayed = 1 # With the pykota filter, accounting is delayed by one job
         
Index: /pykota/trunk/pykota/requester.py
===================================================================
--- /pykota/trunk/pykota/requester.py (revision 1257)
+++ /pykota/trunk/pykota/requester.py (revision 1433)
@@ -22,4 +22,9 @@
 #
 # $Log$
+# Revision 1.13  2004/04/09 22:24:46  jalet
+# 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.
+#
 # Revision 1.12  2004/01/08 14:10:32  jalet
 # Copyright year changed.
@@ -73,7 +78,7 @@
     __str__ = __repr__
     
-def openRequester(config, printername) :
+def openRequester(kotabackend, printername) :
     """Returns a connection handle to the appropriate requester."""
-    (backend, args) = config.getRequesterBackend(printername)
+    (backend, args) = kotabackend.config.getRequesterBackend(printername)
     try :
         exec "from pykota.requesters import %s as requesterbackend" % backend.lower()
@@ -81,3 +86,3 @@
         raise PyKotaRequesterError, _("Unsupported requester backend %s") % backend
     else :    
-        return requesterbackend.Requester(printername, args)
+        return requesterbackend.Requester(kotabackend, printername, args)
Index: /pykota/trunk/bin/cupspykota
===================================================================
--- /pykota/trunk/bin/cupspykota (revision 1411)
+++ /pykota/trunk/bin/cupspykota (revision 1433)
@@ -24,4 +24,9 @@
 #
 # $Log$
+# Revision 1.38  2004/04/09 22:24:46  jalet
+# 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.
+#
 # Revision 1.37  2004/03/18 19:11:25  jalet
 # Fix for raw jobs in cupspykota
@@ -190,26 +195,4 @@
 class PyKotaBackend(PyKotaFilterOrBackend) :        
     """A class for the pykota backend."""
-    def __init__(self) :
-        """Does normal initialization then installs signal handler."""
-        # Normal init
-        PyKotaFilterOrBackend.__init__(self)
-        
-        # then deal with signals
-        # CUPS backends ignore SIGPIPE and exit(1) on SIGTERM
-        # Fortunately SIGPIPE is already ignored by Python
-        # It's there just in case this changes in the future.
-        # Here we have to handle SIGTERM correctly, and pass
-        # it to the original backend if needed.
-        self.gotSigTerm = 0
-        signal.signal(signal.SIGPIPE, signal.SIG_IGN)
-        signal.signal(signal.SIGTERM, self.sigterm_handler)
-        
-    def sigterm_handler(self, signum, frame) :
-        """Sets a global variable whenever SIGTERM is received."""
-        # SIGTERM will be ignore most of the time, but during
-        # the call to the real backend, we have to pass it through.
-        self.gotSigTerm = 1
-        self.logger.log_message(_("SIGTERM received, job %s cancelled.") % self.jobid, "info")
-        
     def acceptJob(self) :        
         """Returns the appropriate exit code to tell CUPS all is OK."""
