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

Method show_dirty

gunicorn/ctl/handlers.py:69–127  ·  view source on GitHub ↗

Return dirty workers and apps information. Returns: Dictionary with: - enabled: Whether dirty arbiter is running - pid: Dirty arbiter PID - workers: List of dirty worker info - apps: List of dirty app specs

(self)

Source from the content-addressed store, hash-verified

67 return {"workers": workers, "count": len(workers)}
68
69 def show_dirty(self) -> dict:
70 """
71 Return dirty workers and apps information.
72
73 Returns:
74 Dictionary with:
75 - enabled: Whether dirty arbiter is running
76 - pid: Dirty arbiter PID
77 - workers: List of dirty worker info
78 - apps: List of dirty app specs
79 """
80 if not self.arbiter.dirty_arbiter_pid:
81 return {
82 "enabled": False,
83 "pid": None,
84 "workers": [],
85 "apps": [],
86 }
87
88 # Get dirty arbiter reference if available
89 dirty_arbiter = getattr(self.arbiter, 'dirty_arbiter', None)
90
91 workers = []
92 apps = []
93
94 if dirty_arbiter and hasattr(dirty_arbiter, 'workers'):
95 now = time.monotonic()
96 for pid, worker in dirty_arbiter.workers.items():
97 try:
98 last_update = worker.tmp.last_update()
99 last_heartbeat = round(now - last_update, 2)
100 except (OSError, ValueError, AttributeError):
101 last_heartbeat = None
102
103 workers.append({
104 "pid": pid,
105 "age": worker.age,
106 "apps": getattr(worker, 'app_paths', []),
107 "booted": getattr(worker, 'booted', False),
108 "last_heartbeat": last_heartbeat,
109 })
110
111 # Get app specs
112 if hasattr(dirty_arbiter, 'app_specs'):
113 for path, spec in dirty_arbiter.app_specs.items():
114 worker_pids = list(dirty_arbiter.app_worker_map.get(path, []))
115 apps.append({
116 "import_path": path,
117 "worker_count": spec.get('worker_count'),
118 "current_workers": len(worker_pids),
119 "worker_pids": worker_pids,
120 })
121
122 return {
123 "enabled": True,
124 "pid": self.arbiter.dirty_arbiter_pid,
125 "workers": workers,
126 "apps": apps,

Callers 2

_handle_showMethod · 0.80

Calls 3

itemsMethod · 0.80
last_updateMethod · 0.80
getMethod · 0.45

Tested by 1