- Timestamp:
- 05/24/04 13:59:51 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r1492 r1493 24 24 # 25 25 # $Log$ 26 # Revision 1.47 2004/05/24 11:59:46 jalet 27 # More robust (?) code 28 # 26 29 # Revision 1.46 2004/05/21 22:02:51 jalet 27 30 # Preliminary work on pre-accounting … … 392 395 # First check if original backend is still alive 393 396 status = subprocess.poll() 394 397 except : 398 self.logdebug("Interrupted Poll") 399 time.sleep(0.01) # give some time to the CPU 400 else : 395 401 # Now if we got SIGTERM, we have 396 402 # to kill -TERM the original backend … … 411 417 for (fd, mask) in availablefds : 412 418 # self.logdebug(self.formatFileEvent(fd, mask, instreams, outstreams)) 413 try : 414 if mask & (select.POLLIN | select.POLLPRI) : 415 # We have something to read 419 if mask & (select.POLLIN | select.POLLPRI) : 420 # We have something to read 421 try : 422 fobj = instreams[fd] 423 except KeyError : 424 self.logdebug("READ : %s" % self.formatFileEvent(fd, mask, instreams, outstreams)) 425 else : 416 426 try : 417 fobj = instreams[fd]418 except KeyError:419 self.logdebug(" READ : %s" % self.formatFileEvent(fd, mask, instreams, outstreams))427 data = fobj["file"].read() 428 except IOError, msg : 429 self.logdebug("Interrupted Read : %s" % msg) 420 430 else : 421 data = fobj["file"].read()422 431 if not data : 423 432 self.logdebug("No more data to read on %s (read returned nothing)" % fobj["name"]) … … 428 437 # self.logdebug("%s -- DATA[%i] <= : %s ..." % (self.formatFileEvent(fd, mask, instreams, outstreams), len(data), data[:50])) 429 438 fout = outstreams[fobj["out"]]["file"] 430 fout.write(data) 431 fout.flush() 432 433 if mask & (select.POLLHUP | select.POLLERR) : 434 # Some pipe has no more datas so we don't 435 # want to continue to poll this file 436 toclose = None 437 try : 438 fobj = instreams[fd] 439 if fobj["name"] == "stdin" : 440 toclose = outstreams[fobj["out"]] 441 self.logdebug("No more data to read from %s (POLLUP or POLLERR received)" % fobj["name"]) 442 except KeyError : 443 fobj = outstreams[fd] 444 if fobj["name"] == "stderr" : 445 toclose = instreams[fobj["in"]] 446 self.logdebug("No more data to write to %s (POLLUP or POLLERR received)" % fobj["name"]) 439 try : 440 fout.write(data) 441 except IOError, msg : 442 self.logdebug("Interrupted Write : %s" % msg) 443 else : 444 try : 445 fout.flush() 446 except IOError, msg : 447 self.logdebug("Interrupted Flush : %s" % msg) 448 449 if mask & (select.POLLHUP | select.POLLERR) : 450 # Some pipe has no more datas so we don't 451 # want to continue to poll this file 452 toclose = None 453 try : 454 fobj = instreams[fd] 455 if fobj["name"] == "stdin" : 456 toclose = outstreams[fobj["out"]] 457 self.logdebug("No more data to read from %s (POLLUP or POLLERR received)" % fobj["name"]) 458 except KeyError : 459 fobj = outstreams[fd] 460 if fobj["name"] == "stderr" : 461 toclose = instreams[fobj["in"]] 462 self.logdebug("No more data to write to %s (POLLUP or POLLERR received)" % fobj["name"]) 463 464 if not fobj["done"] : 465 self.unregisterFileNo(pollster, fd) 466 fobj["done"] = 1 467 if toclose is not None : 468 self.logdebug("Closing %s" % toclose["name"]) 469 try : 470 toclose["file"].close() 471 except : 472 self.logdebug("Interrupted Close") 447 473 448 if not fobj["done"] : 449 self.unregisterFileNo(pollster, fd) 450 fobj["done"] = 1 451 if toclose is not None : 452 self.logdebug("Closing %s" % toclose["name"]) 453 toclose["file"].close() 454 455 if mask & select.POLLNVAL : 456 self.logdebug("CLOSED : %s" % self.formatFileEvent(fd, mask, instreams, outstreams)) 457 458 except IOError, msg : 459 self.logdebug("IOError : %s -- %s" % (msg, self.formatFileEvent(fd, mask, instreams, outstreams))) 460 time.sleep(0.01) # give some time to the CPU 461 except IOError, msg : 462 self.logdebug("IOError : %s" % msg) 463 time.sleep(0.01) # give some time to the CPU 474 if mask & select.POLLNVAL : 475 self.logdebug("CLOSED : %s" % self.formatFileEvent(fd, mask, instreams, outstreams)) 464 476 465 477 self.logdebug("Exiting streams polling loop...") -
pykota/trunk/pykota/loggers/stderr.py
r1457 r1493 22 22 # 23 23 # $Log$ 24 # Revision 1.7 2004/05/24 11:59:49 jalet 25 # More robust (?) code 26 # 24 27 # Revision 1.6 2004/05/07 14:43:44 jalet 25 28 # Now logs the PID too … … 52 55 def log_message(self, message, level="info") : 53 56 """Sends the message to the appropriate logging subsystem.""" 54 sys.stderr.write("%s: PyKota (PID %s) : %s\n" % (level.upper(), os.getpid(), message.strip())) 55 sys.stderr.flush() 57 try : 58 sys.stderr.write("%s: PyKota (PID %s) : %s\n" % (level.upper(), os.getpid(), message.strip())) 59 except IOError : 60 pass # What else could we do ? 61 else : 62 try : 63 sys.stderr.flush() 64 except IOError : 65 pass # What else could we do ? -
pykota/trunk/pykota/loggers/system.py
r1457 r1493 22 22 # 23 23 # $Log$ 24 # Revision 1.11 2004/05/24 11:59:51 jalet 25 # More robust (?) code 26 # 24 27 # Revision 1.10 2004/05/07 14:43:46 jalet 25 28 # Now logs the PID too … … 74 77 """Sends the message to syslog.""" 75 78 priority = getattr(syslog, "LOG_%s" % self.levels.get(level.lower(), "DEBUG").upper(), syslog.LOG_DEBUG) 76 syslog.syslog(priority, "(PID %s) : %s" % (os.getpid(), message.strip())) 79 try : 80 syslog.syslog(priority, "(PID %s) : %s" % (os.getpid(), message.strip())) 81 except : 82 pass # What else could we do ?