File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -1070,7 +1070,7 @@ def caplog_vllm(temporary_enable_log_propagate, caplog):
10701070 yield caplog
10711071
10721072
1073- @pytest .fixture (scope = "session" )
1073+ @pytest .fixture ()
10741074def caplog_mp_fork ():
10751075 """
10761076 This fixture enables capturing logs from a forked MP subprocess.
@@ -1115,7 +1115,7 @@ def __init__(self):
11151115 self .text = None
11161116
11171117
1118- @pytest .fixture (scope = "session" )
1118+ @pytest .fixture ()
11191119def caplog_mp_spawn (tmp_path , monkeypatch ):
11201120 """
11211121 This fixture enables capturing logs from a forked MP subprocess.
Original file line number Diff line number Diff line change @@ -515,5 +515,34 @@ def mp_function(**kwargs):
515515
516516
517517def test_caplog_mp_fork (caplog_vllm , caplog_mp_fork ):
518- pass
519- # TODO
518+ with caplog_vllm .at_level (logging .DEBUG ), caplog_mp_fork ():
519+ import multiprocessing
520+
521+ ctx = multiprocessing .get_context ("fork" )
522+ p = ctx .Process (
523+ target = mp_function ,
524+ name = f"SubProcess{ 1 } " ,
525+ kwargs = {"a" : "AAAA" , "b" : "BBBBB" },
526+ )
527+ p .start ()
528+ p .join ()
529+
530+ assert "AAAA" in caplog_vllm .text
531+ assert "BBBBB" in caplog_vllm .text
532+
533+
534+ def test_caplog_mp_spawn (caplog_mp_spawn ):
535+ with caplog_mp_spawn (logging .DEBUG ) as log_holder :
536+ import multiprocessing
537+
538+ ctx = multiprocessing .get_context ("spawn" )
539+ p = ctx .Process (
540+ target = mp_function ,
541+ name = f"SubProcess{ 1 } " ,
542+ kwargs = {"a" : "AAAA" , "b" : "BBBBB" },
543+ )
544+ p .start ()
545+ p .join ()
546+
547+ assert "AAAA" in log_holder .text
548+ assert "BBBBB" in log_holder .text
You can’t perform that action at this time.
0 commit comments