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

Changeset 1869

Show
Ignore:
Timestamp:
01/18/08 18:00:02
Author:
fumanchu
Message:

Added a warning and auto-exit on main thread exit if the Bus is not shut down. This will help avoid issues like #750.

Files:

Legend:

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

    r1831 r1869  
    6161""" 
    6262 
     63import atexit 
    6364import os 
    6465try: 
     
    7071import time 
    7172import traceback as _traceback 
     73import warnings 
    7274 
    7375 
     
    159161        return output 
    160162     
     163    def _clean_exit(self): 
     164        """An atexit handler which asserts the Bus is not running.""" 
     165        if self.state != states.EXITING: 
     166            warnings.warn( 
     167                "The main thread is exiting, but the Bus is in the %r state; " 
     168                "shutting it down automatically now. You must either call " 
     169                "bus.block() after start(), or call bus.exit() before the " 
     170                "main thread exits." % self.state, RuntimeWarning) 
     171            self.exit() 
     172     
    161173    def start(self): 
    162174        """Start all services.""" 
     175        atexit.register(self._clean_exit) 
     176         
    163177        self.state = states.STARTING 
    164178        self.log('Bus STARTING') 

Hosted by WebFaction

Log in as guest/cpguest to create tickets