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

Changeset 1810

Show
Ignore:
Timestamp:
10/29/07 16:24:31
Author:
fumanchu
Message:

New test and fix for errors during engine.start().

Files:

Legend:

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

    r1759 r1810  
    150150        self.state = states.STARTING 
    151151        self.log('Bus starting') 
    152         self.publish('start') 
     152        try: 
     153            self.publish('start') 
     154        except: 
     155            try: 
     156                self.stop() 
     157            except: 
     158                # Any stop errors will be logged inside publish(). 
     159                pass 
     160            raise 
    153161        self.state = states.STARTED 
    154162     
  • trunk/cherrypy/test/test_states.py

    r1755 r1810  
    307307            if x.args != (10, 'No child processes'): 
    308308                raise 
     309     
     310    def test_5_Start_Error(self): 
     311        if not self.server_class: 
     312            print "skipped (no server) ", 
     313            return 
     314         
     315        # Start the demo script in a new process 
     316        demoscript = os.path.join(os.getcwd(), os.path.dirname(__file__), 
     317                                  "test_states_demo.py") 
     318        host = cherrypy.server.socket_host 
     319        port = cherrypy.server.socket_port 
     320         
     321        # If a process errors during start, it should stop the engine 
     322        # and exit with a non-zero exit code. 
     323        args = [sys.executable, demoscript, host, str(port), '-starterror'] 
     324        if self.scheme == "https": 
     325            args.append('-ssl') 
     326        exit_code = os.spawnl(os.P_WAIT, sys.executable, *args) 
     327        if exit_code == 0: 
     328            self.fail("Process failed to return nonzero exit code.") 
    309329 
    310330 
  • trunk/cherrypy/test/test_states_demo.py

    r1756 r1810  
    6363    cherrypy.engine.subscribe('start', cherrypy.server.quickstart) 
    6464     
     65    if '-starterror' in sys.argv[3:]: 
     66        cherrypy.engine.subscribe('start', lambda: 1/0) 
     67     
    6568    # This is in a special order for a reason: 
    6669    # it allows test_states to wait_for_occupied_port 

Hosted by WebFaction

Log in as guest/cpguest to create tickets