microsoft / ptvsd

Python debugger package for use with Visual Studio and Visual Studio Code.
Other
548 stars 68 forks source link

Debugger Timedout if kept idle for some time #2130

Closed shyamiisc closed 4 years ago

shyamiisc commented 4 years ago

Environment data

Actual behavior

We are using ptvsd in some what different way. We embedded python interpreter in a C++ application. We are using ptvsd to debug the scripts which is written using the API provided by our application. To do that We load PTVSD module in the embedded python interpreter and open a socket to set up a remote debugging session with VSCode. It was working fine so far but now we started seeing timeout issue showing below message where debugging is stopped if kept idle for around 30 seconds.

Exception in thread ptvsd.Server: Traceback (most recent call last): File "/Users/goyals/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/ipcjson.py", line 269, in process_one_message msg = self.__message.pop(0) IndexError: pop from empty list

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/goyals/Library/Application Support/Autodesk/webdeploy/feature--ChangesFromAPIPerforceBranch/5fe9cf01e67436462626acce9bec5ab16b7b3fb7/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/Users/goyals/Library/Application Support/Autodesk/webdeploy/feature--ChangesFromAPIPerforceBranch/5fe9cf01e67436462626acce9bec5ab16b7b3fb7/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/Users/goyals/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/wrapper.py", line 536, in process_messages raise exc File "/Users/goyals/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/wrapper.py", line 521, in process_messages self.process_messages() File "/Users/goyals/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/ipcjson.py", line 258, in process_messages self.process_one_message() File "/Users/goyals/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/ipcjson.py", line 272, in process_one_message self._wait_for_message() File "/Users/goyals/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/ipcjson.py", line 154, in _wait_for_message line = self._buffered_read_line_as_ascii() File "/Users/goyals/.vscode/extensions/ms-python.python-2019.9.34911/pythonFiles/lib/python/ptvsd/ipcjson.py", line 113, in _buffered_read_line_as_ascii temp = self.__socket.recv(1024) socket.timeout: timed out

A similar issue is reported here https://github.com/Microsoft/ptvsd/issues/1113.

I tried setting timeout property to a higher number in launch.json as suggested by some other user's post but that did not help. I am not sure if the connection is dropped by VSCode debug adapter if there is no response in a specified time.

I appreciate if you can provide any suggestion on what might be going wrong here and there is any way we can increase the default time out duration from 30 seconds to some higher number. Thanks.

shyamiisc commented 4 years ago

Hi @karthiknadig, Do you have any suggestion on this? Thanks.

int19h commented 4 years ago

You should switch to https://github.com/microsoft/debugpy for embedding.

If you update your VSCode Python extension, it should take care of the same on client side. Judging by your log, the version you're on is ms-python.python-2019.9.34911, which is very old.

shyamiisc commented 4 years ago

Hi Pavel, I switched to older version to check if is extension version issue or something else. ms-python.python-2019.9.34911 version was working well for us hence tried with it. This problem is happening even with ms-python.python-2020.6.91350.

Just to provide more context this is how we are embedding PTVSD. The following script is executed by the python interpreter embedded in the application import ptvsd ptvsd.enable_attach(address=('127.0.0.1','9000')))

and then we wait for the VSCode to attach using wait_for_attach method import ptvsd ptvsd.wait_for_attach()

As you suggested We will look into debugpy for embedding. Thanks.

shyamiisc commented 4 years ago

ptvsd-12672.log @int19h Attaching a log file for your reference. Thanks for taking a look at it.

int19h commented 4 years ago

To clarify, the newer versions of the Python extensions use debugpy on the client. They might work with ptvsd on the server, but that's an inherently less stable combination.

We're not doing bug fixes in ptvsd at this point - debugpy has diverged so far, the entire layer above pydevd is a complete rewrite, so they're impossible to backport (and some of the problems in ptvsd 4 were architectural, requiring such a rewrite to fix).

marcosscriven commented 4 years ago

@shyamiisc - ironically I found this issue by Googling Fusion 360 debugpy, as I'm trying to debug a Fusion 360 add-in remotely (I.e. a different computer on the network) and it refuses to connect.

Can Fusion 360 Python version be updated per @int19h's suggestion?