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

Method show_all

gunicorn/ctl/handlers.py:457–514  ·  view source on GitHub ↗

Return overview of all processes (arbiter, web workers, dirty arbiter, dirty workers). Returns: Dictionary with complete process hierarchy

(self)

Source from the content-addressed store, hash-verified

455 return {"status": "shutting_down", "mode": mode}
456
457 def show_all(self) -> dict:
458 """
459 Return overview of all processes (arbiter, web workers, dirty arbiter, dirty workers).
460
461 Returns:
462 Dictionary with complete process hierarchy
463 """
464 now = time.monotonic()
465
466 # Arbiter info
467 arbiter_info = {
468 "pid": self.arbiter.pid,
469 "type": "arbiter",
470 "role": "master",
471 }
472
473 # Web workers (HTTP workers)
474 web_workers = []
475 for pid, worker in self.arbiter.WORKERS.items():
476 try:
477 last_update = worker.tmp.last_update()
478 last_heartbeat = round(now - last_update, 2)
479 except (OSError, ValueError):
480 last_heartbeat = None
481
482 web_workers.append({
483 "pid": pid,
484 "type": "web",
485 "age": worker.age,
486 "booted": worker.booted,
487 "last_heartbeat": last_heartbeat,
488 })
489
490 # Sort by age
491 web_workers.sort(key=lambda w: w["age"])
492
493 # Dirty arbiter info (runs in separate process)
494 dirty_arbiter_info = None
495 dirty_workers = []
496
497 if self.arbiter.dirty_arbiter_pid:
498 dirty_arbiter_info = {
499 "pid": self.arbiter.dirty_arbiter_pid,
500 "type": "dirty_arbiter",
501 "role": "dirty master",
502 }
503
504 # Query dirty arbiter for worker info via its socket
505 dirty_workers = self._query_dirty_workers()
506
507 return {
508 "arbiter": arbiter_info,
509 "web_workers": web_workers,
510 "web_worker_count": len(web_workers),
511 "dirty_arbiter": dirty_arbiter_info,
512 "dirty_workers": dirty_workers,
513 "dirty_worker_count": len(dirty_workers),
514 }

Callers 3

test_show_all_basicMethod · 0.95
_handle_showMethod · 0.80

Calls 3

_query_dirty_workersMethod · 0.95
itemsMethod · 0.80
last_updateMethod · 0.80

Tested by 2

test_show_all_basicMethod · 0.76