Index: /pykota/trunk/bin/cupspykota
===================================================================
--- /pykota/trunk/bin/cupspykota (revision 1497)
+++ /pykota/trunk/bin/cupspykota (revision 1498)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.51  2004/05/25 08:31:16  jalet
+# Heavy CPU usage seems to be fixed at least !
+#
 # Revision 1.50  2004/05/25 05:17:50  jalet
 # Now precomputes the job's size only if current printer's enforcement
@@ -414,5 +417,9 @@
             
             # In any case, deal with any remaining I/O
-            availablefds = pollster.poll(5000)
+            try :
+                availablefds = pollster.poll(5000)
+            except select.error, msg :    
+                self.logdebug("Interrupted poll : %s" % msg)
+                availablefds = []
             if not availablefds :
                 self.logdebug("Nothing to do, sleeping a bit...")
@@ -432,4 +439,8 @@
                                     else :    
                                         indata = ""
+                                else :        
+                                    self.logdebug("No data to send to real backend yet, sleeping a bit...")
+                                    time.sleep(0.01)
+                                    
                                 if endinput :    
                                     self.unregisterFileNo(pollster, tocfno)        
@@ -445,7 +456,15 @@
                                     else :
                                         outdata = ""
+                                else :        
+                                    # self.logdebug("No data to send back to CUPS yet, sleeping a bit...") # Uncommenting this fills your logs
+                                    time.sleep(0.01) # Give some time to the system, stderr is ALWAYS writeable it seems.
+                                    
                                 if endoutput :    
                                     self.unregisterFileNo(pollster, stderrfno)        
                                     outputclosed = 1
+                            else :    
+                                self.logdebug("Unexpected : %s - Sleeping a bit..." % self.formatFileEvent(fd, mask))
+                                time.sleep(0.01)
+                                
                         if mask & (select.POLLIN | select.POLLPRI) :     
                             # We have something to read
@@ -456,11 +475,20 @@
                             else :
                                 if fd == infno :
-                                    indata += data
                                     if not data :    # If yes, then no more input data
                                         self.unregisterFileNo(pollster, infno)
                                         self.logdebug("Input data ends.")
                                         endinput = 1 # this happens with real files.
+                                    else :    
+                                        indata += data
                                 elif fd == fromcfno :
-                                    outdata += data
+                                    if not data :
+                                        self.logdebug("No back channel data to read from real backend yet, sleeping a bit...")
+                                        time.sleep(0.01)
+                                    else :
+                                        outdata += data
+                                else :    
+                                    self.logdebug("Unexpected : %s - Sleeping a bit..." % self.formatFileEvent(fd, mask))
+                                    time.sleep(0.01)
+                                    
                         if mask & (select.POLLHUP | select.POLLERR) :
                             # Treat POLLERR as an EOF.
@@ -477,4 +505,7 @@
                                 os.close(fromcfno)
                                 endoutput = 1
+                            else :    
+                                self.logdebug("Unexpected : %s - Sleeping a bit..." % self.formatFileEvent(fd, mask))
+                                time.sleep(0.01)
                                 
                         if mask & select.POLLNVAL :        
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 1497)
+++ /pykota/trunk/NEWS (revision 1498)
@@ -24,4 +24,7 @@
     - 1.19alpha14 :
     
+        - Heavy CPU usage is now completely fixed it seems, by 
+          introducing some 0.01 second sleeping when nothing to do.
+          
         - Pre-computation of the job's size is now only
           done when enforcement is "STRICT", this saves
