Vendor debugpy for VS Code attach debugging
Bundles debugpy 1.7.0 directly in python/ so "Maya: Attach (debugpy)" works with no per-machine pip install step. Installed via Maya 2022's own pip so it resolved a version actually compatible with Python 3.7 (Maya 2022's interpreter), then verified import + listen() succeeds under all three target Maya Python versions (3.7/3.9/3.10). Also fixes a latent __file__-under-exec() bug in start_debug_server.py (same pitfall as Maya's own plugin loader, never hit until this exercised it) and corrects the README's Maya Python version claim -- 2022 ships Python 3.7, not 3.9 as previously stated, which was never independently verified until now. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See LICENSE in the project root
|
||||
# for license information.
|
||||
|
||||
"""Provides facilities to dump all stacks of all threads in the process.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
import traceback
|
||||
|
||||
from debugpy.common import log
|
||||
|
||||
|
||||
def dump():
|
||||
"""Dump stacks of all threads in this process, except for the current thread."""
|
||||
|
||||
tid = threading.current_thread().ident
|
||||
pid = os.getpid()
|
||||
|
||||
log.info("Dumping stacks for process {0}...", pid)
|
||||
|
||||
for t_ident, frame in sys._current_frames().items():
|
||||
if t_ident == tid:
|
||||
continue
|
||||
|
||||
for t in threading.enumerate():
|
||||
if t.ident == tid:
|
||||
t_name = t.name
|
||||
t_daemon = t.daemon
|
||||
break
|
||||
else:
|
||||
t_name = t_daemon = "<unknown>"
|
||||
|
||||
stack = "".join(traceback.format_stack(frame))
|
||||
log.info(
|
||||
"Stack of thread {0} (tid={1}, pid={2}, daemon={3}):\n\n{4}",
|
||||
t_name,
|
||||
t_ident,
|
||||
pid,
|
||||
t_daemon,
|
||||
stack,
|
||||
)
|
||||
|
||||
log.info("Finished dumping stacks for process {0}.", pid)
|
||||
|
||||
|
||||
def dump_after(secs):
|
||||
"""Invokes dump() on a background thread after waiting for the specified time."""
|
||||
|
||||
def dumper():
|
||||
time.sleep(secs)
|
||||
try:
|
||||
dump()
|
||||
except:
|
||||
log.swallow_exception()
|
||||
|
||||
thread = threading.Thread(target=dumper)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
Reference in New Issue
Block a user