Gevent debug support

Posted on by Dmitry Trofimov

Good news for everyone who uses gevent!

Since the last PyCharm 2.6 EAP our visual debugger is able to deal with gevent monkey-patched code.

To enable it just edit python/helpers/pydev/pydevd_constants.py in PyCharm installation and set the constant SUPPORT_GEVENT=True

Your feedback is welcome as always!

Update: In recent versions of PyCharm, the option has moved to the main settings dialog. You can enable it under Settings | Python Debugger | Gevent compatible debugging.

Comments below can no longer be edited.

12 Responses to Gevent debug support

  1. Trung Ly says:

    September 26, 2012

    This helped me out a lot. Thanks!

    Any plans to do it in a non-hackish (like in Settings) way in the future?

  2. Lew says:

    October 11, 2012

    This is great. We’ve been using this a ton!

    Having trouble getting remote debugging with gevent working though. Is this supported? (I can connect but breakpoints aren’t being hit.)

    Thanks!

    -Lew

  3. Lukman says:

    December 7, 2012

    I become a Jetbrains clenit past year, buying the Personal License for PyCharm 1.0, but my license will expire next month in October, 28.I’ve to buy a new license for the version 2.0, if the final release occur after the expiration of my license or I’ll be called to renew my license? Sorry, but I really don’t know how is the process to continue to getting support for PyCharm.Thanks in advance.

  4. Hann says:

    June 18, 2013

    Setting SUPPORT_GEVENT = True raises

    Exception KeyError: KeyError(4332526160,) in ignored

    while debugging. The problem is attached to importing threading module before monkey patching. My platform is PyCharm 2.7.3 build #129.782

    http://stackoverflow.com/questions/8774958/keyerror-in-module-threading-after-a-successful-py-test-run

    Those who face the same problem, please confirm.

    • traff says:

      June 20, 2013

      Hi Hann,
      thanks for sharing the link!

      PyCharm’s debugger uses threading module internally, but the problem can be solved, I’ve create an issue regarding the problem http://youtrack.jetbrains.com/issue/PY-10054

  5. tracy jones says:

    November 21, 2013

    I am also having an issue where i can connect but breakpoints are not being hit. I set
    GEVENT_SUPPORT on the client side and enabled gevent debugging on the server side. But no breakpoints.

    • Nate Thelen says:

      October 27, 2014

      We are having the same exact problem. Anyone resolve it?

      • Edilio Gallardo says:

        January 14, 2015

        It is SUPPORT_GEVENT = True instead of GEVENT_SUPPORT.

        I added a little bit more of code into a github project to make easier debugging using .env files like http://12factor.net/ suggests. Here is the code:
        pycharm-helper

        • David Hesson says:

          June 24, 2015

          This still isn’t working for me. My behavior is slightly bizarre – the breakpoint is hit, but no variables load and no thread/stack information loads, and all the step buttons stay grayed out. The debugger just says “Connected” and never changes state. So frustrating right now. I’m using 4.5.x and I have enabled “Gevent compatible debugging” in settings with no luck.

  6. fefe says:

    April 25, 2016

    in pycharm 2.6.1.2
    my solution works

    cd /Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle
    vi pydevd_constants.py
    under import gevent add one line: SUPPORT_GEVENT = True

    try:
    SUPPORT_GEVENT = os.getenv(‘GEVENT_SUPPORT’, ‘False’) == ‘True’
    try:
    import gevent
    SUPPORT_GEVENT = True #add this line
    except:
    SUPPORT_GEVENT = False
    except:
    # Jython 2.1 doesn’t accept that construct
    SUPPORT_GEVENT = False

  7. Amir says:

    December 31, 2019

    This fix worked for me, but then today it stopped working and I get the RecursiveError on S3 access when I run a unittest (what I got before the fix).
    Version: pycharm-community-2018.2.2
    Fixed File: /helpers/pydev/_pydevd_bundle/pydevd_constants.py
    Python: 3.6.9
    Any suggestion?
    Thanks a lot

Subscribe

Subscribe for updates