1717from opsqueue .consumer import Strategy
1818
1919
20- _sigusr1_dump_file : Any | None = None
21-
22-
2320def _stack_dump_path (pid : int ) -> Path :
2421 return Path (f"/tmp/opsqueue-pytest-stack-{ pid } .log" )
2522
2623
27- def _linux_child_pids (parent_pid : int ) -> dict [int , tuple [str , str ]]:
24+ def _linux_descendant_pids (parent_pid : int ) -> dict [int , tuple [str , str ]]:
2825 children_file = Path (f"/proc/{ parent_pid } /task/{ parent_pid } /children" )
2926 try :
3027 raw = children_file .read_text (encoding = "utf-8" ).strip ()
@@ -49,11 +46,14 @@ def _child_command(pid: int) -> tuple[str, str]:
4946 return ("<comm>" , "<cmdline>" )
5047
5148 pids = [int (pid_text ) for pid_text in raw .split () if pid_text .isdigit ()]
52- return {pid : _child_command (pid ) for pid in pids }
49+ result = {pid : _child_command (pid ) for pid in pids }
50+ for pid in pids :
51+ result .update (_linux_descendant_pids (pid ))
52+ return result
5353
5454
5555def _handle_sigterm (signum : int , frame : object ) -> None :
56- worker_pids = _linux_child_pids (os .getpid ())
56+ worker_pids = _linux_descendant_pids (os .getpid ())
5757 if worker_pids :
5858 print (
5959 f"[opsqueue pytest] Requesting stack dump from child workers: { worker_pids .keys ()} " ,
@@ -122,11 +122,10 @@ def _handle_sigterm(signum: int, frame: object) -> None:
122122
123123
124124# Register signal handlers at module import time (before pytest_configure hook runs).
125- _sigusr1_dump_file = _stack_dump_path (os .getpid ()).open ("w" , encoding = "utf-8" )
126125# Make SIGUSR1 print a traceback in any process (controller or worker).
127126faulthandler .register (
128127 signal .SIGUSR1 ,
129- file = _sigusr1_dump_file ,
128+ file = _stack_dump_path ( os . getpid ()). open ( "w" , encoding = "utf-8" ) ,
130129 all_threads = True ,
131130 chain = False ,
132131)
0 commit comments