Index: /pykota/trunk/pykota/loggers/stderr.py
===================================================================
--- /pykota/trunk/pykota/loggers/stderr.py (revision 1457)
+++ /pykota/trunk/pykota/loggers/stderr.py (revision 1493)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.7  2004/05/24 11:59:49  jalet
+# More robust (?) code
+#
 # Revision 1.6  2004/05/07 14:43:44  jalet
 # Now logs the PID too
@@ -52,4 +55,11 @@
     def log_message(self, message, level="info") :
         """Sends the message to the appropriate logging subsystem."""
-        sys.stderr.write("%s: PyKota (PID %s) : %s\n" % (level.upper(), os.getpid(), message.strip()))
-        sys.stderr.flush()
+        try :
+            sys.stderr.write("%s: PyKota (PID %s) : %s\n" % (level.upper(), os.getpid(), message.strip()))
+        except IOError :    
+            pass # What else could we do ?
+        else :    
+            try :
+                sys.stderr.flush()
+            except IOError :    
+                pass # What else could we do ?
Index: /pykota/trunk/pykota/loggers/system.py
===================================================================
--- /pykota/trunk/pykota/loggers/system.py (revision 1457)
+++ /pykota/trunk/pykota/loggers/system.py (revision 1493)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.11  2004/05/24 11:59:51  jalet
+# More robust (?) code
+#
 # Revision 1.10  2004/05/07 14:43:46  jalet
 # Now logs the PID too
@@ -74,3 +77,6 @@
         """Sends the message to syslog."""
         priority = getattr(syslog, "LOG_%s" % self.levels.get(level.lower(), "DEBUG").upper(), syslog.LOG_DEBUG)
-        syslog.syslog(priority, "(PID %s) : %s" % (os.getpid(), message.strip()))
+        try :
+            syslog.syslog(priority, "(PID %s) : %s" % (os.getpid(), message.strip()))
+        except :    
+            pass # What else could we do ?
Index: /pykota/trunk/bin/cupspykota
===================================================================
--- /pykota/trunk/bin/cupspykota (revision 1492)
+++ /pykota/trunk/bin/cupspykota (revision 1493)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.47  2004/05/24 11:59:46  jalet
+# More robust (?) code
+#
 # Revision 1.46  2004/05/21 22:02:51  jalet
 # Preliminary work on pre-accounting
@@ -392,5 +395,8 @@
                 # First check if original backend is still alive
                 status = subprocess.poll()
-                
+            except :    
+                self.logdebug("Interrupted Poll")
+                time.sleep(0.01) # give some time to the CPU
+            else :
                 # Now if we got SIGTERM, we have 
                 # to kill -TERM the original backend
@@ -411,13 +417,16 @@
                     for (fd, mask) in availablefds :
                         # self.logdebug(self.formatFileEvent(fd, mask, instreams, outstreams))
-                        try :
-                            if mask & (select.POLLIN | select.POLLPRI) :     
-                                # We have something to read
+                        if mask & (select.POLLIN | select.POLLPRI) :     
+                            # We have something to read
+                            try :
+                                fobj = instreams[fd]
+                            except KeyError :    
+                                self.logdebug("READ : %s" % self.formatFileEvent(fd, mask, instreams, outstreams))
+                            else :    
                                 try :
-                                    fobj = instreams[fd]
-                                except KeyError :    
-                                    self.logdebug("READ : %s" % self.formatFileEvent(fd, mask, instreams, outstreams))
+                                    data = fobj["file"].read()
+                                except IOError, msg :    
+                                    self.logdebug("Interrupted Read : %s" % msg)
                                 else :    
-                                    data = fobj["file"].read()
                                     if not data :
                                         self.logdebug("No more data to read on %s (read returned nothing)" % fobj["name"])
@@ -428,38 +437,41 @@
                                         # self.logdebug("%s -- DATA[%i] <= : %s ..." % (self.formatFileEvent(fd, mask, instreams, outstreams), len(data), data[:50]))
                                         fout = outstreams[fobj["out"]]["file"]
-                                        fout.write(data)
-                                        fout.flush()
-                                            
-                            if mask & (select.POLLHUP | select.POLLERR) :
-                                # Some pipe has no more datas so we don't
-                                # want to continue to poll this file
-                                toclose = None
-                                try :
-                                    fobj = instreams[fd]
-                                    if fobj["name"] == "stdin" :
-                                        toclose = outstreams[fobj["out"]]
-                                    self.logdebug("No more data to read from %s (POLLUP or POLLERR received)" % fobj["name"])
-                                except KeyError :    
-                                    fobj = outstreams[fd]
-                                    if fobj["name"] == "stderr" :
-                                        toclose = instreams[fobj["in"]]
-                                    self.logdebug("No more data to write to %s (POLLUP or POLLERR received)" % fobj["name"])
+                                        try :
+                                            fout.write(data)
+                                        except IOError, msg :    
+                                            self.logdebug("Interrupted Write : %s" % msg)
+                                        else :    
+                                            try :
+                                                fout.flush()
+                                            except IOError, msg :    
+                                                self.logdebug("Interrupted Flush : %s" % msg)
+                                        
+                        if mask & (select.POLLHUP | select.POLLERR) :
+                            # Some pipe has no more datas so we don't
+                            # want to continue to poll this file
+                            toclose = None
+                            try :
+                                fobj = instreams[fd]
+                                if fobj["name"] == "stdin" :
+                                    toclose = outstreams[fobj["out"]]
+                                self.logdebug("No more data to read from %s (POLLUP or POLLERR received)" % fobj["name"])
+                            except KeyError :    
+                                fobj = outstreams[fd]
+                                if fobj["name"] == "stderr" :
+                                    toclose = instreams[fobj["in"]]
+                                self.logdebug("No more data to write to %s (POLLUP or POLLERR received)" % fobj["name"])
+                                
+                            if not fobj["done"] :
+                                self.unregisterFileNo(pollster, fd)
+                                fobj["done"] = 1
+                                if toclose is not None :
+                                    self.logdebug("Closing %s" % toclose["name"])
+                                    try :
+                                        toclose["file"].close()
+                                    except :    
+                                        self.logdebug("Interrupted Close")
                                     
-                                if not fobj["done"] :
-                                    self.unregisterFileNo(pollster, fd)
-                                    fobj["done"] = 1
-                                    if toclose is not None :
-                                        self.logdebug("Closing %s" % toclose["name"])
-                                        toclose["file"].close()
-                                        
-                            if mask & select.POLLNVAL :            
-                                self.logdebug("CLOSED : %s" % self.formatFileEvent(fd, mask, instreams, outstreams))
-                                
-                        except IOError, msg :                
-                            self.logdebug("IOError : %s -- %s" % (msg, self.formatFileEvent(fd, mask, instreams, outstreams)))
-                            time.sleep(0.01) # give some time to the CPU
-            except IOError, msg :
-                self.logdebug("IOError : %s" % msg)
-                time.sleep(0.01) # give some time to the CPU
+                        if mask & select.POLLNVAL :            
+                            self.logdebug("CLOSED : %s" % self.formatFileEvent(fd, mask, instreams, outstreams))
                 
         self.logdebug("Exiting streams polling loop...")
