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

Adapter times out when running from Maya #334

Closed
luabud opened this issue Jul 11, 2020 · 9 comments
Closed

Adapter times out when running from Maya #334

luabud opened this issue Jul 11, 2020 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@luabud
Copy link
Member

luabud commented Jul 11, 2020

import cube
# Error: RuntimeError: file C:\Program Files\Autodesk\Maya2020\Python\lib\site-packages\debugpy\server\api.py line 224: timed out waiting for adapter to connect # 

cube.py:

import maya.cmds as mc
import debugpy 
import time

#while debugpy.is_client_connected():
#    time.sleep(0.5)

debugpy.listen(("localhost",5678))
debugpy.wait_for_client()

debugpy.breakpoint()
r = mc.polyCube(w=2,h=9,d=2)

debugpy.breakpoint()
print("hey!")

Run selection for "import cube"

@fabioz
Copy link
Collaborator

fabioz commented Jul 16, 2020

I don't really have Maya to test and it seems to work for me in the usual attach to port 5678... Do you know which Python version is Maya using?

One thing to try: replace localhost with 127.0.0.1 (both in the launch and in debugpy.listen).

If it doesn't work, please provide the logs (from Maya and from VSCode).

To get the logs from Maya, you should be able to do something as:

import debugpy
debugpy.log_to('c:/temp')

To get the logs from VSCode:

  • Open VS Code
  • Select the command Extensions: Open Extensions Folder
  • Locate the Python extension directory, typically of the form ms-python.python-2020..***
  • In that directory ensure you do not have any debug*.log files, if you do, please delete them
  • Go back into VS Code and modify your launch.json to add the setting "logToFile": true to the attach, see below:
"version": "0.2.0",
"configurations": [
        {
            "name": "Python Attach to 5678",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "127.0.0.1",
            "logToFile": true,
        },```

* Start debugging
* When done, go back into the extension directory and upload the debug*.log files into this GitHub issue.

@int19h
Copy link
Contributor

int19h commented Jul 16, 2020

We had a collaborative debug session about this, and it's pretty complicated (there are various things that seem to not work in Maya). I'll investigate it further.

@int19h int19h self-assigned this Jul 16, 2020
@fabioz
Copy link
Collaborator

fabioz commented Jul 16, 2020

As a note, I believe that plain pydevd does work in Maya using the remote attach (from reports I got in the past), so, my hunch is that this is related to launching the secondary adapter process/connecting to it, but if it turns out you need something on the pydevd side, please let me know.

@luabud
Copy link
Member Author

luabud commented Jul 20, 2020

FWIW Maya uses Python 2.7 😅 and I manually added debugpy to site-packages because they seem to use some sort of custom Python.

@munkybutt
Copy link

Are there any updates on this?
I am having the same problem in 3DsMax using debugpy where as pydevd used to work without issue.

@daniele-niero
Copy link

Same here

@bob-white
Copy link
Contributor

bob-white commented Aug 25, 2020

I'm running into a similar problem with our own application that embeds python.
The issue seems to be that debugpy.listen spawns a subprocess using sys.executable which will fail for Maya/Max/Our Tool. Because these aren't standard python processes that accept standard python arguments.

It would be nice if we could specify a python-process instead.

In fact, just changing sys.executable in the listen function to 'python' was enough for me to get vs_code to connect properly. Not sure how true this is for other programs, I haven't tested Max/Maya.

@RockShea
Copy link

I was considering the same approach, pointing it at the Max specific python exe.
Haven't had a chance to test yet.
If it is possible, it would be great to have this be exposed as a setting.

@int19h
Copy link
Contributor

int19h commented Aug 25, 2020

Ah, that makes sense! It would be #262, then.

@int19h int19h closed this as completed Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants