MCPcopy Create free account
hub / github.com/pyload/pyload / shrink

Method shrink

module/lib/wsgiserver/__init__.py:1325–1340  ·  view source on GitHub ↗

Kill off worker threads (not below self.min).

(self, amount)

Source from the content-addressed store, hash-verified

1323 worker.start()
1324
1325 def shrink(self, amount):
1326 """Kill off worker threads (not below self.min)."""
1327 # Grow/shrink the pool if necessary.
1328 # Remove any dead threads from our list
1329 for t in self._threads:
1330 if not t.isAlive():
1331 self._threads.remove(t)
1332 amount -= 1
1333
1334 if amount > 0:
1335 for i in xrange(min(amount, len(self._threads) - self.min)):
1336 # Put a number of shutdown requests on the queue equal
1337 # to 'amount'. Once each of those is processed by a worker,
1338 # that worker will terminate and be culled from our list
1339 # in self.put.
1340 self._queue.put(_SHUTDOWNREQUEST)
1341
1342 def stop(self, timeout=5):
1343 # Must shut down threads here so the code that calls

Callers

nothing calls this directly

Calls 2

removeMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected