Skip to content

Commit

Permalink
Avoid calling get_backlog twice
Browse files Browse the repository at this point in the history
Fix failing lint tests
  • Loading branch information
raags committed Nov 15, 2023
1 parent 9e308f5 commit 0d12c43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions gunicorn/arbiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/sock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0d12c43

Please sign in to comment.