Bump cheroot from 9.0.0 to 10.0.0 (#2128)

* Bump cheroot from 9.0.0 to 10.0.0

Bumps [cheroot](https://github.com/cherrypy/cheroot) from 9.0.0 to 10.0.0.
- [Release notes](https://github.com/cherrypy/cheroot/releases)
- [Changelog](https://github.com/cherrypy/cheroot/blob/main/CHANGES.rst)
- [Commits](https://github.com/cherrypy/cheroot/compare/v9.0.0...v10.0.0)

---
updated-dependencies:
- dependency-name: cheroot
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update cheroot==10.0.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
This commit is contained in:
dependabot[bot] 2023-08-24 12:09:15 -07:00 committed by GitHub
parent 9423f65a90
commit 4033114175
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 215 additions and 85 deletions

View file

@ -151,12 +151,33 @@ class ThreadPool:
server (cheroot.server.HTTPServer): web server object
receiving this request
min (int): minimum number of worker threads
max (int): maximum number of worker threads
max (int): maximum number of worker threads (-1/inf for no max)
accepted_queue_size (int): maximum number of active
requests in queue
accepted_queue_timeout (int): timeout for putting request
into queue
:raises ValueError: if the min/max values are invalid
:raises TypeError: if the max is not an integer or inf
"""
if min < 1:
raise ValueError(f'min={min!s} must be > 0')
if max == float('inf'):
pass
elif not isinstance(max, int) or max == 0:
raise TypeError(
'Expected an integer or the infinity value for the `max` '
f'argument but got {max!r}.',
)
elif max < 0:
max = float('inf')
if max < min:
raise ValueError(
f'max={max!s} must be > min={min!s} (or infinity for no max)',
)
self.server = server
self.min = min
self.max = max
@ -167,18 +188,13 @@ class ThreadPool:
self._pending_shutdowns = collections.deque()
def start(self):
"""Start the pool of threads."""
for _ in range(self.min):
self._threads.append(WorkerThread(self.server))
for worker in self._threads:
worker.name = (
'CP Server {worker_name!s}'.
format(worker_name=worker.name)
)
worker.start()
for worker in self._threads:
while not worker.ready:
time.sleep(.1)
"""Start the pool of threads.
:raises RuntimeError: if the pool is already started
"""
if self._threads:
raise RuntimeError('Threadpools can only be started once.')
self.grow(self.min)
@property
def idle(self): # noqa: D401; irrelevant for properties
@ -206,17 +222,13 @@ class ThreadPool:
def grow(self, amount):
"""Spawn new worker threads (not above self.max)."""
if self.max > 0:
budget = max(self.max - len(self._threads), 0)
else:
# self.max <= 0 indicates no maximum
budget = float('inf')
budget = max(self.max - len(self._threads), 0)
n_new = min(amount, budget)
workers = [self._spawn_worker() for i in range(n_new)]
while not all(worker.ready for worker in workers):
time.sleep(.1)
for worker in workers:
while not worker.ready:
time.sleep(.1)
self._threads.extend(workers)
def _spawn_worker(self):