v0lta
v0lta

Reputation: 653

How do I turn off the "Evaluating: plt.show() did not finish after 3.00s seconds." warning in the VsCode debugger?

I often debug my python code by plotting NumPy arrays in the vscode debugger. Often I spend more than 3s looking at a plot. When I do vscode prints the extremely long warning below. It's very annoying because I then have to scroll up a lot all the time to see previous debugging outputs. Where is this PYDEVD_WARN_EVALUATION_TIMEOUT variable? How do I turn this off?

I included the warning below for completeness, thanks a lot for your help!

Evaluating: plt.show() did not finish after 3.00s seconds. This may mean a number of things:

  • This evaluation is really slow and this is expected. In this case it's possible to silence this error by raising the timeout, setting the PYDEVD_WARN_EVALUATION_TIMEOUT environment variable to a bigger value.

  • The evaluation may need other threads running while it's running: In this case, it's possible to set the PYDEVD_UNBLOCK_THREADS_TIMEOUT environment variable so that if after a given timeout an evaluation doesn't finish, other threads are unblocked or you can manually resume all threads.

    Alternatively, it's also possible to skip breaking on a particular thread by setting a pydev_do_not_trace = True attribute in the related threading.Thread instance (if some thread should always be running and no breakpoints are expected to be hit in it).

  • The evaluation is deadlocked: In this case you may set the PYDEVD_THREAD_DUMP_ON_WARN_EVALUATION_TIMEOUT environment variable to true so that a thread dump is shown along with this message and optionally, set the PYDEVD_INTERRUPT_THREAD_TIMEOUT to some value so that the debugger tries to interrupt the evaluation (if possible) when this happens.

Upvotes: 21

Views: 16593

Answers (4)

v0lta
v0lta

Reputation: 653

If found a way to adapt the launch.json which takes care of this problem.

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Python: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "env": {"PYTHONPATH": "${workspaceRoot}",
                    "PYDEVD_WARN_EVALUATION_TIMEOUT": "500"},
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal"
        }
    ]
}

Upvotes: 32

parched
parched

Reputation: 631

For anyone wanting to adjust it in the current session (e.g., because you've attached to a live process you don't want to restart) try this from the debug console.

import _pydevd_bundle.pydevd_constants
_pydevd_bundle.pydevd_constants.PYDEVD_WARN_EVALUATION_TIMEOUT = 30. # seconds

Reference

Upvotes: 6

Lord ST
Lord ST

Reputation: 533

based on here, you can simply set the timeout parameter of debug configuration(launch.json). for example, sth like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "timeout": 10,
            "program": "${workspaceFolder}/src/manage.py",
            "args": [
                "runserver"
            ],
            "django": true
        }
    ]
}

Upvotes: -1

AEM
AEM

Reputation: 13

If you are keen to surpress the warning, you'd go like this:

In this documentation, point 28.6.3, you can do so: https://docs.python.org/2/library/warnings.html#temporarily-suppressing-warnings

Here's the code if the link dies in the future.

import warnings

def fxn():
    warnings.warn("deprecated", DeprecationWarning)

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    fxn()

You should be ready to go with a simple copy paste.

Upvotes: -3

Related Questions