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

Changeset 1950

Show
Ignore:
Timestamp:
04/26/08 18:07:53
Author:
fumanchu
Message:

Fix for #806 (Move dead thread detection). Consumers can call shrink() anytime they want.

Files:

Legend:

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

    r1948 r1950  
    10921092        if obj is _SHUTDOWNREQUEST: 
    10931093            return 
    1094          
    1095         # Grow/shrink the pool if necessary. 
    1096         # Remove any dead threads from our list 
    1097         for t in self._threads: 
    1098             if not t.isAlive(): 
    1099                 self._threads.remove(t) 
    11001094     
    11011095    def grow(self, amount): 
     
    11111105    def shrink(self, amount): 
    11121106        """Kill off worker threads (not below self.min).""" 
    1113         for i in xrange(min(amount, len(self._threads) - self.min)): 
    1114             # Put a number of shutdown requests on the queue equal 
    1115             # to 'amount'. Once each of those is processed by a worker, 
    1116             # that worker will terminate and be culled from our list 
    1117             # in self.put. 
    1118             self._queue.put(_SHUTDOWNREQUEST) 
     1107        # Grow/shrink the pool if necessary. 
     1108        # Remove any dead threads from our list 
     1109        for t in self._threads: 
     1110            if not t.isAlive(): 
     1111                self._threads.remove(t) 
     1112                amount -= 1 
     1113         
     1114        if amount > 0: 
     1115            for i in xrange(min(amount, len(self._threads) - self.min)): 
     1116                # Put a number of shutdown requests on the queue equal 
     1117                # to 'amount'. Once each of those is processed by a worker, 
     1118                # that worker will terminate and be culled from our list 
     1119                # in self.put. 
     1120                self._queue.put(_SHUTDOWNREQUEST) 
    11191121     
    11201122    def stop(self, timeout=5): 

Hosted by WebFaction

Log in as guest/cpguest to create tickets