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

Changeset 1816

Show
Ignore:
Timestamp:
11/02/07 17:27:23
Author:
lakin
Message:

Fixing the bug exposed by the unit test I just committed in : http://cherrypy.org/changeset/1815 . The fix is to catch SystemExit? errors and if we have a pending exception cause by earlier errors, we ensure that the exit code is not zero. Additionally due to some better understandings of what fork does, we move fork further back in the startup process. However, fork has issues when threads are already open, so we shuffle around the default priorities of various plugins to ensure all threads are started after Daemonization.

Files:

Legend:

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

    r1759 r1816  
    165165                self.bus.log('umask old: %03o, new: %03o' % 
    166166                                (old_umask, umask)) 
    167     start.priority = 70 
     167    start.priority = 75 
    168168 
    169169 
     
    187187     
    188188    def start(self): 
     189        # forking has issues with threads: 
     190        # http://www.opengroup.org/onlinepubs/000095399/functions/fork.html 
     191        # " ... The general problem with making fork() work in a multi-threaded world 
     192        #  is what to do with all of the threads. ... " 
     193        # So we check for active threads: 
     194        if threading.activeCount() != 1: 
     195            self.bus.log('There are more than one active threads. Daemonizing now may cause strange failures.') 
     196            self.bus.log(str(threading.enumerate())) 
     197 
    189198        # See http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16 
    190199        # (or http://www.faqs.org/faqs/unix-faq/programmer/faq/ section 1.7) 
     
    237246         
    238247        self.bus.log('Daemonized to PID: %s' % os.getpid()) 
    239     start.priority = 10 
     248    start.priority = 65 
    240249 
    241250 
     
    298307            self.thread.start() 
    299308            self.bus.log("Started thread %r." % threadname) 
     309    start.priority = 70 
    300310     
    301311    def stop(self): 
     
    330340        self.mtimes = {} 
    331341        Monitor.start(self) 
     342    start.priority = 70  
    332343     
    333344    def run(self): 
  • trunk/cherrypy/restsrv/wspbus.py

    r1813 r1816  
    136136            try: 
    137137                output.append(listener(*args, **kwargs)) 
    138             except (KeyboardInterrupt, SystemExit)
     138            except KeyboardInterrupt
    139139                raise 
     140            except SystemExit, e: 
     141                # If we have previous errors ensure the exit code is non-zero 
     142                if exc and e.code == 0: 
     143                    e.code = 1 
     144                raise  
    140145            except: 
    141146                self.log("Error in %r listener %r" % (channel, listener), 

Hosted by WebFaction

Log in as guest/cpguest to create tickets