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

Changeset 2037

Show
Ignore:
Timestamp:
09/27/08 13:28:04
Author:
fumanchu
Message:

Bus.wait may now take a list or tuple for the 'state' arg, to wait on any of multiple states.

Files:

Legend:

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

    r2012 r2037  
    9999     
    100100    def wait(self, state, interval=0.1): 
    101         """Wait for the given state, KeyboardInterrupt or SystemExit. 
     101        """Wait for the given state(s), KeyboardInterrupt or SystemExit. 
    102102         
    103103        Since this class uses native win32event objects, the interval 
    104104        argument is ignored. 
    105105        """ 
    106         # Don't wait for an event that beat us to the punch ;) 
    107         if self.state != state: 
    108             event = self._get_state_event(state) 
    109             win32event.WaitForSingleObject(event, win32event.INFINITE) 
     106        if isinstance(state, (tuple, list)): 
     107            # Don't wait for an event that beat us to the punch ;) 
     108            if self.state not in state: 
     109                events = tuple([self._get_state_event(s) for s in state]) 
     110                win32event.WaitForMultipleObjects(events, 0, win32event.INFINITE) 
     111        else: 
     112            # Don't wait for an event that beat us to the punch ;) 
     113            if self.state != state: 
     114                event = self._get_state_event(state) 
     115                win32event.WaitForSingleObject(event, win32event.INFINITE) 
    110116 
    111117 
  • trunk/cherrypy/process/wspbus.py

    r2027 r2037  
    253253     
    254254    def wait(self, state, interval=0.1): 
    255         """Wait for the given state.""" 
     255        """Wait for the given state(s).""" 
     256        if isinstance(state, (tuple, list)): 
     257            states = state 
     258        else: 
     259            states = [state] 
     260         
    256261        def _wait(): 
    257             while self.state != state
     262            while self.state not in states
    258263                time.sleep(interval) 
    259264         

Hosted by WebFaction

Log in as guest/cpguest to create tickets