@@ -441,7 +441,7 @@ def show_all(self) -> dict:
441441 # Sort by age
442442 web_workers .sort (key = lambda w : w ["age" ])
443443
444- # Dirty arbiter and workers
444+ # Dirty arbiter info (runs in separate process)
445445 dirty_arbiter_info = None
446446 dirty_workers = []
447447
@@ -452,26 +452,8 @@ def show_all(self) -> dict:
452452 "role" : "dirty master" ,
453453 }
454454
455- # Get dirty workers if we have access
456- dirty_arbiter = getattr (self .arbiter , 'dirty_arbiter' , None )
457- if dirty_arbiter and hasattr (dirty_arbiter , 'workers' ):
458- for pid , worker in dirty_arbiter .workers .items ():
459- try :
460- last_update = worker .tmp .last_update ()
461- last_heartbeat = round (now - last_update , 2 )
462- except (OSError , ValueError , AttributeError ):
463- last_heartbeat = None
464-
465- dirty_workers .append ({
466- "pid" : pid ,
467- "type" : "dirty" ,
468- "age" : worker .age ,
469- "apps" : getattr (worker , 'app_paths' , []),
470- "booted" : getattr (worker , 'booted' , False ),
471- "last_heartbeat" : last_heartbeat ,
472- })
473-
474- dirty_workers .sort (key = lambda w : w ["age" ])
455+ # Query dirty arbiter for worker info via its socket
456+ dirty_workers = self ._query_dirty_workers ()
475457
476458 return {
477459 "arbiter" : arbiter_info ,
@@ -482,6 +464,47 @@ def show_all(self) -> dict:
482464 "dirty_worker_count" : len (dirty_workers ),
483465 }
484466
467+ def _query_dirty_workers (self ) -> list :
468+ """
469+ Query the dirty arbiter for worker information.
470+
471+ Connects to the dirty arbiter socket and sends a status request.
472+
473+ Returns:
474+ List of dirty worker info dicts, or empty list on error
475+ """
476+ import socket
477+ dirty_socket_path = os .environ .get ('GUNICORN_DIRTY_SOCKET' )
478+ if not dirty_socket_path :
479+ return []
480+
481+ try :
482+ from gunicorn .dirty .protocol import DirtyProtocol
483+
484+ sock = socket .socket (socket .AF_UNIX , socket .SOCK_STREAM )
485+ sock .settimeout (2.0 )
486+ sock .connect (dirty_socket_path )
487+
488+ # Send status request
489+ request = {
490+ "type" : DirtyProtocol .MSG_TYPE_STATUS ,
491+ "id" : "ctl-status-1" ,
492+ }
493+ DirtyProtocol .write_message (sock , request )
494+
495+ # Read response
496+ response = DirtyProtocol .read_message (sock )
497+ sock .close ()
498+
499+ if response .get ("type" ) == DirtyProtocol .MSG_TYPE_RESPONSE :
500+ data = response .get ("data" , {})
501+ return data .get ("workers" , [])
502+
503+ except Exception :
504+ pass
505+
506+ return []
507+
485508 def help (self ) -> dict :
486509 """
487510 Return list of available commands.
0 commit comments