Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1759

Show
Ignore:
Timestamp:
10/19/07 13:18:50
Author:
fumanchu
Message:

More bus logging.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/restsrv/plugins.py

    r1757 r1759  
    9090        _signal.signal(signum, self._handle_signal) 
    9191        if listener is not None: 
     92            self.bus.log("Listening for %s." % signame) 
    9293            self.bus.subscribe(signame, listener) 
    9394     
    9495    def _handle_signal(self, signum=None, frame=None): 
    9596        """Python signal handler (self.set_handler subscribes it for you).""" 
    96         self.bus.publish(self.signals[signum]) 
     97        signame = self.signals[signum] 
     98        self.bus.log("Caught signal %s." % signame) 
     99        self.bus.publish(signame) 
    97100 
    98101 
     
    200203            else: 
    201204                # This is the first parent. Exit, now that we've forked. 
     205                self.bus.log('Forking once.') 
    202206                sys.exit(0) 
    203207        except OSError, exc: 
     
    212216            pid = os.fork() 
    213217            if pid > 0: 
     218                self.bus.log('Forking twice.') 
    214219                sys.exit(0) # Exit second parent 
    215220        except OSError, exc: 
     
    243248     
    244249    def start(self): 
    245         open(self.pidfile, "wb").write(str(os.getpid())) 
     250        pid = os.getpid() 
     251        open(self.pidfile, "wb").write(str(pid)) 
     252        self.bus.log('PID %r written to %r.' % (pid, self.pidfile)) 
    246253    start.priority = 70 
    247254     
     
    249256        try: 
    250257            os.remove(self.pidfile) 
     258            self.bus.log('PID file removed: %r.' % self.pidfile) 
    251259        except (KeyboardInterrupt, SystemExit): 
    252260            raise 
     
    285293        """Start our callback in its own perpetual timer thread.""" 
    286294        if self.frequency > 0: 
     295            threadname = "restsrv %s" % self.__class__.__name__ 
    287296            self.thread = PerpetualTimer(self.frequency, self.callback) 
    288             self.thread.setName("restsrv %s" % self.__class__.__name__
     297            self.thread.setName(threadname
    289298            self.thread.start() 
     299            self.bus.log("Started thread %r." % threadname) 
    290300     
    291301    def stop(self): 
     
    295305                self.thread.cancel() 
    296306                self.thread.join() 
     307                self.bus.log("Stopped thread %r." % self.thread.getName()) 
    297308            self.thread = None 
    298309     
  • trunk/cherrypy/restsrv/wspbus.py

    r1758 r1759  
    8484 
    8585class Bus(object): 
    86     """Process state-machine and messenger for HTTP site deployment.""" 
     86    """Process state-machine and messenger for HTTP site deployment. 
     87     
     88    All listeners for a given channel are guaranteed to be called even 
     89    if others at the same channel fail. Each failure is logged, but 
     90    execution proceeds on to the next listener. The only way to stop all 
     91    processing from inside a listener is to raise SystemExit and stop the 
     92    whole server. 
     93    """ 
    8794     
    8895    states = states 
     
    127134        items.sort() 
    128135        for priority, listener in items: 
    129             # All listeners for a given channel are guaranteed to run even 
    130             # if others at the same channel fail. We will still log the 
    131             # failure, but proceed on to the next listener. The only way 
    132             # to stop all processing from one of these listeners is to 
    133             # raise SystemExit and stop the whole server. 
    134136            try: 
    135137                output.append(listener(*args, **kwargs)) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets