MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / print_thread_stacks

Function print_thread_stacks

test/helpers_shared.py:190–204  ·  view source on GitHub ↗

Print all C-level thread stacks for a given process id.

(pid: int)

Source from the content-addressed store, hash-verified

188
189
190def print_thread_stacks(pid: int) -> None:
191 """Print all C-level thread stacks for a given process id."""
192 if sys.platform == "darwin":
193 cmd = ["lldb", "--attach-pid", f"{pid}", "--batch", "--one-line", '"thread backtrace all"']
194 else:
195 cmd = ["gdb", f"--pid={pid}", "--batch", '--eval-command="thread apply all bt"']
196
197 try:
198 res = subprocess.run(
199 cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding="utf-8"
200 )
201 except Exception as exc:
202 sys.stderr.write(f"Could not print C-level thread stacks because {cmd[0]} failed: {exc}")
203 else:
204 sys.stderr.write(res.stdout)
205
206
207def _get_executors(topology):

Callers 2

forkMethod · 0.90
forkMethod · 0.90

Calls 2

runMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected