summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2020-10-22 02:59:10 -0500
committerMichael Merickel <michael@merickel.org>2020-10-22 02:59:10 -0500
commit78e98a75e527f90d8d8f2a25f5cb3f26527e75b4 (patch)
treeb110b8db0879ca14fdcb900c697536c39a3c1c76
parent734014d34b1139b753457694f7b583c230e5bb14 (diff)
downloadwaitress-78e98a75e527f90d8d8f2a25f5cb3f26527e75b4.tar.gz
only change state while accepting
-rw-r--r--src/waitress/server.py40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/waitress/server.py b/src/waitress/server.py
index 639b9de..631780b 100644
--- a/src/waitress/server.py
+++ b/src/waitress/server.py
@@ -298,25 +298,27 @@ class BaseWSGIServer(wasyncore.dispatcher):
self.next_channel_cleanup = now + self.adj.cleanup_interval
self.maintenance(now)
- if (
- not self.in_connection_overflow
- and len(self._map) >= self.adj.connection_limit
- ):
- self.in_connection_overflow = True
- self.logger.warning(
- 'server active connections reached the connection limit, '
- 'no longer accepting new connections'
- )
- elif (
- self.in_connection_overflow
- and len(self._map) < self.adj.connection_limit
- ):
- self.in_connection_overflow = False
- self.logger.info(
- 'server active connections dropped below the connection limit, '
- 'listening again'
- )
- return self.accepting and not self.in_connection_overflow
+ if self.accepting:
+ if (
+ not self.in_connection_overflow
+ and len(self._map) >= self.adj.connection_limit
+ ):
+ self.in_connection_overflow = True
+ self.logger.warning(
+ 'total open connections reached the connection limit, '
+ 'no longer accepting new connections'
+ )
+ elif (
+ self.in_connection_overflow
+ and len(self._map) < self.adj.connection_limit
+ ):
+ self.in_connection_overflow = False
+ self.logger.info(
+ 'total open connections dropped below the connection limit, '
+ 'listening again'
+ )
+ return not self.in_connection_overflow
+ return False
def writable(self):
return False