Skip to content

Support gevent 20.12.1 #515

@plenzjr

Description

@plenzjr

Environment data

  • VS Code version: 1.52.1
  • OS and version: Ubuntu 20.04
  • Python version: 3.8.5
  • Type of virtual environment used: venv
  • Relevant/affected Python packages and their versions: Flask, gevent
  • Relevant/affected Python-related VS Code extensions and their versions: Python, v2020.12.424452561,
  • Debugpy version: 1.2.1

Actual behavior

Running the app from the debug console doesn't stop in some breakpoints and a warning is printed.

Expected behavior

Stop in all breakpoints and resolve warnings

Steps to reproduce:

  • setup a virtualenv

    1. python3 -m ./.venv example
    2. source ./.venv/bin/activate
  • install packages

    1. python3 -m pip install flask gevent
  • create file run.py

from gevent import monkey
monkey.patch_all()


from flask import Flask
from datetime import datetime
import re


app = Flask(__name__)


@app.route("/")
def home():
    print('start')
    print('set a breakpoint')
    print('should stop')
    return "Hello, Flask!"


@app.route("/hello/<name>")
def hello_there(name):
    now = datetime.now()
    formatted_now = now.strftime("%A, %d %B, %Y at %X")

    # Filter the name argument to letters only using regular expressions. URL arguments
    # can contain arbitrary text, so we restrict to safe characters only.
    match_object = re.match("[a-zA-Z]+", name)

    if match_object:
        clean_name = match_object.group(0)
    else:
        clean_name = "Friend"

    content = "Hello there, " + clean_name + "! It's " + formatted_now
    return content


if __name__ == "__main__":
    app.run(host='0.0.0.0', port=5100, debug=True, threaded=True, use_reloader=False)
  • configure files:
    1. launch.json
{
    "configurations": [
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "module": "flask",
            "cwd": "${workspaceRoot}",
            "env": {
                "FLASK_APP": "run.py",
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "0"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload",
                "--port=5100"
            ],
            "jinja": true,
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}
  1. settings.json
{
    "python.pythonPath": "${env:HOME}/.venv/example/bin/python",
}

Run from debug

Logs

  • logs from console
PYDEV DEBUGGER WARNING:
sys.settrace() should not be used when the debugger is being used.
This may cause the debugger to stop working correctly.
If this is needed, please check: 
http://pydev.blogspot.com/2007/06/why-cant-pydev-debugger-work-with.html
to see how to restore the debug tracing back correctly.
Call Location:
  File "${HOME}/.venv/example/lib/python3.8/site-packages/gevent/threadpool.py", line 157, in _before_run_task
    _sys.settrace(_get_thread_trace())


PYDEV DEBUGGER WARNING:
sys.settrace() should not be used when the debugger is being used.
This may cause the debugger to stop working correctly.
If this is needed, please check: 
http://pydev.blogspot.com/2007/06/why-cant-pydev-debugger-work-with.html
to see how to restore the debug tracing back correctly.
Call Location:
  File "${HOME}/.venv/example/lib/python3.8/site-packages/gevent/threadpool.py", line 162, in _after_run_task
    _sys.settrace(None)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions