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

Function code_to_debug

tests/debugpy/test_multiproc.py:51–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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
104 def grandchild(q, a):
105 print("entering grandchild")
106 assert q.get() == "grandchild_pid?"
107 a.put(("grandchild_pid", os.getpid()))
108

Callers

nothing calls this directly

Calls 2

parentFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…