MCPcopy Create free account
hub / github.com/microsoft/debugpy / test_multiprocessing

Function test_multiprocessing

tests/debugpy/test_multiproc.py:46–163  ·  view source on GitHub ↗
(pyfile, target, run, start_method)

Source from the content-addressed store, hash-verified

44 ["spawn"] if sys.platform == "win32" else ["spawn", "fork"],
45)
46def test_multiprocessing(pyfile, target, run, start_method):
47 if start_method == "spawn" and sys.platform != "win32":
48 pytest.skip("https://github.com/microsoft/ptvsd/issues/1887")
49
50 @pyfile
51 def code_to_debug():
52 import debuggee
53 import multiprocessing
54 import os
55 import sys
56
57 # https://github.com/microsoft/ptvsd/issues/2108
58 class Foo(object):
59 pass
60
61 def parent(q, a):
62 from debuggee import backchannel
63
64 debuggee.setup()
65
66 print("spawning child")
67 p = multiprocessing.Process(target=child, args=(q, a))
68 p.start()
69 print("child spawned")
70
71 q.put("foo?")
72 foo = a.get()
73 assert isinstance(foo, Foo), repr(foo)
74
75 q.put("child_pid?")
76 what, child_pid = a.get()
77 assert what == "child_pid"
78 backchannel.send(child_pid)
79
80 q.put("grandchild_pid?")
81 what, grandchild_pid = a.get()
82 assert what == "grandchild_pid"
83 backchannel.send(grandchild_pid)
84
85 assert backchannel.receive() == "continue"
86 q.put("exit!")
87 p.join()
88
89 def child(q, a):
90 print("entering child") # @bp
91 assert q.get() == "foo?"
92 a.put(Foo())
93
94 assert q.get() == "child_pid?"
95 a.put(("child_pid", os.getpid()))
96
97 print("spawning child of child")
98 p = multiprocessing.Process(target=grandchild, args=(q, a))
99 p.start()
100 p.join()
101
102 print("leaving child")
103

Callers

nothing calls this directly

Calls 13

open_backchannelMethod · 0.80
wait_for_next_eventMethod · 0.80
popMethod · 0.80
proceedMethod · 0.80
set_breakpointsMethod · 0.80
wait_for_stopMethod · 0.80
request_continueMethod · 0.80
runFunction · 0.70
targetFunction · 0.70
startMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…