| 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) |
|---|