Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging Maya userSetup.py at startup? #51

Open
YKdvd opened this issue Apr 28, 2020 · 2 comments
Open

Debugging Maya userSetup.py at startup? #51

YKdvd opened this issue Apr 28, 2020 · 2 comments

Comments

@YKdvd
Copy link

YKdvd commented Apr 28, 2020

I'm trying to debug our Python code at Maya startup time, in userSetup.py files. With no support for Maya debug configurations, I put a confirmDialog() at the top of userSetup.py, to give me a chance to do the Attach to Process... in PyCharm. However, the attachment won't happen while the confirmation dialog is up. I tried adding a call to maya.utils.processIdleEvents() and a second confirmDialog() after doing the attachment, in hopes that might help, but no.

I'm not sure if the UI confirmDialog() is preventing handling whatever port communication PyCharm is making to the process to connect to the debugger, or if it is simply not attachable until later in startup, after userSetup.py has finished. Is there a way to debug breakpoints in userSetup.py code in the Maya GUI app?

@cmcpasserby
Copy link
Owner

There is a good chance things are not setup enough yet for some things to work during the userSetup calls.

Have you tried using evalDeferred in your startup code.

if i have time i will try some tests to see if i can debug startup code over the weekend.

@YKdvd
Copy link
Author

YKdvd commented Apr 30, 2020

The same thing happens in code run at evalDeferred time. But even at userSetup time, Python should be fully initialized (sitecustomize has been run, for example), and Maya itself has been set up to the point where it's UI is available for my confirmDialog() call.

I think the problem is that confirmDialog() is locking into some sort of relatively tight event loop. The Python GIL is being held, or some other failure-to-yield scenario is happening. pydevd seems to be doing some complex shenanigans to execute some code in the context of the mayapy process, and I suspect that while the confirmDialog() is being displayed, mayapy isn't able to respond to that as it would otherwise.

I may try to replace the dialog with a 30-second loop that calls processIdleEvents() and anything else that might help yield, and see if the attach works then. I can also try doing a mayapy Python Console in Pycharm and use the Attach in that, before calling maya.standalone.initialize() to start Maya up - if that works than it will at least let me debug the part of the startup code that isn't doing UI stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants