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

Changeset 2443

Show
Ignore:
Timestamp:
06/14/09 18:44:18
Author:
fumanchu
Message:

Ported wspbus.ChannelFailures? to trunk from python3.

Files:

Legend:

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

    r2366 r2443  
    7373import warnings 
    7474 
    75  
    7675# Here I save the value of os.getcwd(), which, if I am imported early enough, 
    7776# will be the directory from which the startup script was run.  This is needed 
     
    8180# sys.executable is a relative-path, and/or cause other problems). 
    8281_startup_cwd = os.getcwd() 
     82 
     83class ChannelFailures(Exception): 
     84    delimiter = '\n' 
     85     
     86    def __init__(self, *args, **kwargs): 
     87        super(ChannelFailures, self).__init__(*args, **kwargs) 
     88        self._exceptions = list() 
     89     
     90    def handle_exception(self): 
     91        self._exceptions.append(sys.exc_info()) 
     92     
     93    def get_instances(self): 
     94        return [instance for cls, instance, traceback in self._exceptions] 
     95     
     96    def __str__(self): 
     97        exception_strings = map(repr, self.get_instances()) 
     98        return self.delimiter.join(exception_strings) 
     99     
     100    def __nonzero__(self): 
     101        return bool(self._exceptions) 
    83102 
    84103# Use a flag to indicate the state of the bus. 
     
    145164            return [] 
    146165         
    147         exc = None 
     166        exc = ChannelFailures() 
    148167        output = [] 
    149168         
     
    162181                raise 
    163182            except: 
    164                 exc = sys.exc_info()[1] 
     183                exc.handle_exception() 
    165184                if channel == 'log': 
    166185                    # Assume any further messages to 'log' will fail. 
     
    170189                             level=40, traceback=True) 
    171190        if exc: 
    172             raise 
     191            raise exc 
    173192        return output 
    174193     

Hosted by WebFaction

Log in as guest/cpguest to create tickets