Adjust the number of available threads by setting C{min} and C{max} to new values. @param minthreads: The new value for L{ThreadPool.min}. @param maxthreads: The new value for L{ThreadPool.max}.
(
self, minthreads: int | None = None, maxthreads: int | None = None
)
| 300 | thread.join() |
| 301 | |
| 302 | def adjustPoolsize( |
| 303 | self, minthreads: int | None = None, maxthreads: int | None = None |
| 304 | ) -> None: |
| 305 | """ |
| 306 | Adjust the number of available threads by setting C{min} and C{max} to |
| 307 | new values. |
| 308 | |
| 309 | @param minthreads: The new value for L{ThreadPool.min}. |
| 310 | |
| 311 | @param maxthreads: The new value for L{ThreadPool.max}. |
| 312 | """ |
| 313 | if minthreads is None: |
| 314 | minthreads = self.min |
| 315 | if maxthreads is None: |
| 316 | maxthreads = self.max |
| 317 | |
| 318 | assert minthreads >= 0, "minimum is negative" |
| 319 | assert minthreads <= maxthreads, "minimum is greater than maximum" |
| 320 | |
| 321 | self.min = minthreads |
| 322 | self.max = maxthreads |
| 323 | if not self.started: |
| 324 | return |
| 325 | |
| 326 | # Kill of some threads if we have too many. |
| 327 | if self.workers > self.max: |
| 328 | self._team.shrink(self.workers - self.max) |
| 329 | # Start some threads if we have too few. |
| 330 | if self.workers < self.min: |
| 331 | self._team.grow(self.min - self.workers) |
| 332 | |
| 333 | def dumpStats(self) -> None: |
| 334 | """ |