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

Changeset 1434

Show
Ignore:
Timestamp:
11/18/06 12:44:48
Author:
fumanchu
Message:

Engine.stop was calling monitor_thread.cancel() but not .join(). Engine.monitor_thread is also now a PerpetualTimer?, so it keeps the same thread rather than spawning new ones on each run.

Files:

Legend:

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

    r1383 r1434  
    3333 
    3434 
     35class PerpetualTimer(threading._Timer): 
     36     
     37    def run(self): 
     38        while True: 
     39            self.finished.wait(self.interval) 
     40            if self.finished.isSet(): 
     41                return 
     42            self.function(*self.args, **self.kwargs) 
     43 
     44 
    3545class Engine(object): 
    3646    """Application interface for (HTTP) servers, plus process controls.""" 
     
    7282        freq = self.deadlock_poll_freq 
    7383        if freq > 0: 
    74             self.monitor_thread = threading.Timer(freq, self.monitor) 
     84            self.monitor_thread = PerpetualTimer(freq, self.monitor) 
     85            self.monitor_thread.setName("CPEngine Monitor") 
    7586            self.monitor_thread.start() 
    7687         
     
    163174            if self.monitor_thread: 
    164175                self.monitor_thread.cancel() 
     176                self.monitor_thread.join() 
    165177                self.monitor_thread = None 
    166178             
     
    212224     
    213225    def monitor(self): 
    214         """Check timeout on all responses (starts a recurring Timer thread).""" 
     226        """Check timeout on all responses.""" 
    215227        if self.state == STARTED: 
    216228            for req, resp in self.servings: 
    217229                resp.check_timeout() 
    218         freq = self.deadlock_poll_freq 
    219         self.monitor_thread = threading.Timer(freq, self.monitor) 
    220         self.monitor_thread.start() 
    221230     
    222231    def start_with_callback(self, func, args=None, kwargs=None): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets