""" def _emit(self, eventDict): if eventDict["isError"]: if 'failure' in eventDict: text = eventDict['failure'].getTraceback() else: text = " ".join([str(m) for m in eventDict["message"]]) + "\n" sys.stderr.write(text) sys.stderr.flush() def start(self): addObserver(self._emit) def stop(self): removeObserver(self._emit) # Some more sibling imports, at the bottom and unqualified to avoid # unresolvable circularity import threadable, failure threadable.synchronize(LogPublisher) try: defaultObserver except NameError: defaultObserver = DefaultObserver() defaultObserver.start()
try: counter = int(string.split(name, '.')[-1]) if counter: result.append(counter) except ValueError: pass result.sort() return result def __getstate__(self): state = BaseLogFile.__getstate__(self) del state["size"] return state threadable.synchronize(LogFile) class DailyLogFile(BaseLogFile): """A log file that is rotated daily (at or after midnight localtime) """ def _openFile(self): BaseLogFile._openFile(self) self.lastDate = self.toDate(os.stat(self.path)[8]) def shouldRotate(self): """Rotate when the date has changed since last write""" return self.toDate() > self.lastDate def toDate(self, *args): """Convert a unixtime to (year, month, day) localtime tuple,
try: apply(function, args, kwargs) except: log.msg('Thread raised an exception.') traceback.print_exc(file=log.logfile) log.logOwner.disown(owner) del self.working[ct] self.threads.remove(ct) self.workers = self.workers-1 def stop(self): """Shutdown the threads in the threadpool.""" self.dumpStats() self.joined=1 threads = copy.copy(self.threads) for thread in range(self.workers): self.q.put(WorkerStop) # and let's just make sure for thread in threads: thread.join() def dumpStats(self): print 'queue:',self.q.queue print 'waiters:',self.waiters print 'workers:',self.working print 'total:',self.threads threadable.synchronize(ThreadPool)
try: apply(function, args, kwargs) except: log.msg("Thread raised an exception.") traceback.print_exc(file=log.logfile) log.logOwner.disown(owner) del self.working[ct] self.threads.remove(ct) self.workers = self.workers - 1 def stop(self): """Shutdown the threads in the threadpool.""" self.dumpStats() self.joined = 1 threads = copy.copy(self.threads) for thread in range(self.workers): self.q.put(WorkerStop) # and let's just make sure for thread in threads: thread.join() def dumpStats(self): print "queue:", self.q.queue print "waiters:", self.waiters print "workers:", self.working print "total:", self.threads threadable.synchronize(ThreadPool)
for name in glob.glob("%s.*" % self.path): try: counter = int(string.split(name, '.')[-1]) if counter: result.append(counter) except ValueError: pass result.sort() return result def __getstate__(self): state = LogFile.__getstate__(self) del state["size"] return state threadable.synchronize(LogFile) class DailyLogFile(BaseLogFile): """A log file that is rotated daily (at or after midnight localtime) """ def _openFile(self): BaseLogFile._openFile(self) self.lastDate = self.toDate(os.stat(self.path)[8]) def shouldRotate(self): """Rotate when the date has changed since last write""" return self.toDate() > self.lastDate def toDate(self, *args): """Convert a unixtime to (year, month, day) localtime tuple, or return the current (year, month, day) localtime tuple.