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

Changeset 1989

Show
Ignore:
Timestamp:
06/24/08 00:18:26
Author:
fumanchu
Message:

Moved all bus plugins onto the engine object itself, and fixed a couple bus details along the way.

Files:

Legend:

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

    r1961 r1989  
    175175    from cherrypy.process import win32 
    176176    engine = win32.Win32Bus() 
    177     _console_control_handler = win32.ConsoleCtrlHandler(engine) 
    178     # If you don't want a ConsoleControlHandler, 
    179     # unsubscribe this before calling engine.start(). 
    180     _console_control_handler.subscribe() 
     177    engine.console_control_handler = win32.ConsoleCtrlHandler(engine) 
    181178    del win32 
    182179except ImportError: 
     
    204201        for req, resp in self.servings: 
    205202            resp.check_timeout() 
    206 timeout_monitor = _TimeoutMonitor(engine) 
    207 timeout_monitor.subscribe() 
    208  
    209 # Add an autoreloader (the 'engine' config namespace may detach/attach it). 
     203engine.timeout_monitor = _TimeoutMonitor(engine) 
     204engine.timeout_monitor.subscribe() 
     205 
    210206engine.autoreload = process.plugins.Autoreloader(engine) 
    211207engine.autoreload.subscribe() 
    212208 
    213 process.plugins.ThreadManager(engine).subscribe() 
    214  
    215 signal_handler = process.plugins.SignalHandler(engine) 
     209engine.thread_manager = process.plugins.ThreadManager(engine) 
     210engine.thread_manager.subscribe() 
     211 
     212engine.signal_handler = process.plugins.SignalHandler(engine) 
     213 
    216214 
    217215from cherrypy import _cpserver 
     
    243241        tree.mount(root, script_name, config) 
    244242     
    245     signal_handler.subscribe() 
     243    if hasattr(engine, "signal_handler"): 
     244        engine.signal_handler.subscribe() 
     245    if hasattr(engine, "console_control_handler"): 
     246        engine.console_control_handler.subscribe() 
     247     
    246248    engine.start() 
    247249    engine.block() 
  • trunk/cherrypy/_cpconfig.py

    r1930 r1989  
    306306        engine.autoreload.files = v 
    307307    elif k == 'deadlock_poll_freq': 
    308         cherrypy.timeout_monitor.frequency = v 
     308        engine.timeout_monitor.frequency = v 
    309309    elif k == 'SIGHUP': 
    310310        engine.listeners['SIGHUP'] = set([v]) 
  • trunk/cherrypy/_cpmodpy.py

    r1982 r1989  
    2222                            'log.screen': False, 
    2323                            'show_tracebacks': False}) 
    24      
    25     # Turn off the builtin signal handlers, which can interact 
    26     # in strange ways with the Apache process. 
    27     cherrypy.engine.SIGHUP = None 
    28     cherrypy.engine.SIGTERM = None 
    29      
    30     # You must start the engine in a non-blocking fashion 
    31     # so that mod_python can proceed 
    32     cherrypy.engine.start() 
    3324 
    3425########################################## 
     
    9889                            }) 
    9990     
    100     if hasattr(cherrypy, '_console_control_handler'): 
    101         cherrypy._console_control_handler.unsubscribe() 
    102     cherrypy.engine.autoreload.unsubscribe() 
     91    engine = cherrypy.engine 
     92    if hasattr(engine, "signal_handler"): 
     93        engine.signal_handler.unsubscribe() 
     94    if hasattr(engine, "console_control_handler"): 
     95        engine.console_control_handler.unsubscribe() 
     96    engine.autoreload.unsubscribe() 
    10397    cherrypy.server.unsubscribe() 
    10498     
     
    115109        # Also, "When server is not specified...LogLevel does not apply..." 
    116110        apache.log_error(msg, newlevel, req.server) 
    117     cherrypy.engine.subscribe('log', _log) 
    118      
    119     cherrypy.engine.start() 
     111    engine.subscribe('log', _log) 
     112     
     113    engine.start() 
    120114     
    121115    def cherrypy_cleanup(data): 
    122         cherrypy.engine.exit() 
     116        engine.exit() 
    123117    try: 
    124118        # apache.register_cleanup wasn't available until 3.1.4. 
  • trunk/cherrypy/_cptree.py

    r1938 r1989  
    109109        resp = self.response_class() 
    110110        cherrypy.serving.load(req, resp) 
    111         cherrypy.timeout_monitor.acquire() 
     111        cherrypy.engine.timeout_monitor.acquire() 
    112112        cherrypy.engine.publish('acquire_thread') 
    113113         
     
    118118        req = cherrypy.serving.request 
    119119         
    120         cherrypy.timeout_monitor.release() 
     120        cherrypy.engine.timeout_monitor.release() 
    121121         
    122122        try: 
  • trunk/cherrypy/cherryd

    r1987 r1989  
    2626        plugins.PIDFile(engine, pidfile).subscribe() 
    2727     
    28     cherrypy.signal_handler.subscribe() 
     28    if hasattr(engine, "signal_handler"): 
     29        engine.signal_handler.subscribe() 
     30    if hasattr(engine, "console_control_handler"): 
     31        engine.console_control_handler.subscribe() 
    2932     
    3033    if fastcgi: 
  • trunk/cherrypy/process/plugins.py

    r1938 r1989  
    361361                self.thread.setName(threadname) 
    362362                self.thread.start() 
    363                 self.bus.log("Started thread %r." % threadname) 
     363                self.bus.log("Started monitor thread %r." % threadname) 
    364364            else: 
    365                 self.bus.log("Thread %r already started." % threadname) 
     365                self.bus.log("Monitor thread %r already started." % threadname) 
    366366    start.priority = 70 
    367367     
  • trunk/cherrypy/process/win32.py

    r1938 r1989  
    2121    def start(self): 
    2222        if self.is_set: 
     23            self.bus.log('Handler for console events already set.', level=40) 
    2324            return 
    2425         
     
    2829                         win32api.GetLastError(), level=40) 
    2930        else: 
     31            self.bus.log('Set handler for console events.', level=40) 
    3032            self.is_set = True 
    3133     
    3234    def stop(self): 
    3335        if not self.is_set: 
     36            self.bus.log('Handler for console events already off.', level=40) 
    3437            return 
    3538         
     
    4447                         win32api.GetLastError(), level=40) 
    4548        else: 
     49            self.bus.log('Removed handler for console events.', level=40) 
    4650            self.is_set = False 
    4751     
  • trunk/cherrypy/process/wspbus.py

    r1938 r1989  
    201201        self.log('Bus EXITING') 
    202202        self.publish('exit') 
     203        # This isn't strictly necessary, but it's better than seeing 
     204        # "Waiting for child threads to terminate..." and then nothing. 
     205        self.log('Bus EXITED') 
    203206     
    204207    def restart(self): 
  • trunk/cherrypy/test/helper.py

    r1867 r1989  
    110110    cherrypy.config.reset() 
    111111    setConfig(conf) 
    112     cherrypy.signal_handler.subscribe() 
     112    engine = cherrypy.engine 
     113    if hasattr(engine, "signal_handler"): 
     114        engine.signal_handler.subscribe() 
     115    if hasattr(engine, "console_control_handler"): 
     116        engine.console_control_handler.subscribe() 
    113117    # The Pybots automatic testing system needs the suite to exit 
    114118    # with a non-zero value if there were any problems. 
    115119    # Might as well stick it in the engine... :/ 
    116     cherrypy.engine.test_success = True 
    117     cherrypy.engine.start_with_callback(_run_test_suite_thread, 
    118                                         args=(moduleNames, conf)) 
    119     cherrypy.engine.block() 
    120     if cherrypy.engine.test_success: 
     120    engine.test_success = True 
     121    engine.start_with_callback(_run_test_suite_thread, 
     122                               args=(moduleNames, conf)) 
     123    engine.block() 
     124    if engine.test_success: 
    121125        return 0 
    122126    else: 
  • trunk/cherrypy/test/test_states.py

    r1870 r1989  
    230230        cherrypy.server.start() 
    231231        try: 
    232             self.assertNotEqual(cherrypy.timeout_monitor.thread, None) 
     232            self.assertNotEqual(engine.timeout_monitor.thread, None) 
    233233             
    234234            # Request a "normal" page. 
    235             self.assertEqual(cherrypy.timeout_monitor.servings, []) 
     235            self.assertEqual(engine.timeout_monitor.servings, []) 
    236236            self.getPage("/") 
    237237            self.assertBody("Hello World") 
    238238            # request.close is called async. 
    239             while cherrypy.timeout_monitor.servings: 
     239            while engine.timeout_monitor.servings: 
    240240                print ".", 
    241241                time.sleep(0.01) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets