MCPcopy
hub / github.com/benoitc/gunicorn / show_workers

Method show_workers

gunicorn/ctl/handlers.py:34–67  ·  view source on GitHub ↗

Return list of HTTP workers. Returns: Dictionary with workers list containing: - pid: Worker process ID - age: Worker age (spawn order) - requests: Number of requests handled (if available) - booted: Whether worker has fin

(self)

Source from the content-addressed store, hash-verified

32 self.arbiter = arbiter
33
34 def show_workers(self) -> dict:
35 """
36 Return list of HTTP workers.
37
38 Returns:
39 Dictionary with workers list containing:
40 - pid: Worker process ID
41 - age: Worker age (spawn order)
42 - requests: Number of requests handled (if available)
43 - booted: Whether worker has finished booting
44 - last_heartbeat: Seconds since last heartbeat
45 """
46 workers = []
47 now = time.monotonic()
48
49 for pid, worker in self.arbiter.WORKERS.items():
50 try:
51 last_update = worker.tmp.last_update()
52 last_heartbeat = round(now - last_update, 2)
53 except (OSError, ValueError):
54 last_heartbeat = None
55
56 workers.append({
57 "pid": pid,
58 "age": worker.age,
59 "booted": worker.booted,
60 "aborted": worker.aborted,
61 "last_heartbeat": last_heartbeat,
62 })
63
64 # Sort by age (oldest first)
65 workers.sort(key=lambda w: w["age"])
66
67 return {"workers": workers, "count": len(workers)}
68
69 def show_dirty(self) -> dict:
70 """

Callers 3

_handle_showMethod · 0.80

Calls 2

itemsMethod · 0.80
last_updateMethod · 0.80

Tested by 2