diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 341844811..815ac5d3d 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -584,11 +584,11 @@ def manage_workers(self): "value": active_worker_count, "mtype": "gauge"}) - backlog = sum([ - sock.get_backlog() + backlog = sum( + sock.get_backlog() or 0 for sock in self.LISTENERS - if sock.get_backlog() is not None - ]) + ) + if backlog: self.log.debug("socket backlog: {0}".format(backlog), extra={"metric": "gunicorn.backlog", diff --git a/gunicorn/sock.py b/gunicorn/sock.py index 747199d1c..f88bac626 100644 --- a/gunicorn/sock.py +++ b/gunicorn/sock.py @@ -97,7 +97,7 @@ def set_options(self, sock, bound=False): def get_backlog(self): if self.sock and PLATFORM == "linux": # tcp_info struct from include/uapi/linux/tcp.h - fmt = 'B'*8+'I'*24 + fmt = 'B' * 8 + 'I' * 24 try: tcp_info_struct = self.sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_INFO, 104)