4

I am trying to do remote debug with PyCharm+Pydevd on python code.

The code I try to remote debug is below:

#!/usr/bin/python
import eventlet
eventlet.monkey_patch()

def main():
    import pydevd
    pydevd.settrace('10.84.101.215', port=11111, stdoutToServer=True, stderrToServer=True)
    print "Done"

if __name__ == '__main__':
    main()

Please note that if I comment the line

eventlet.monkey_patch()

The remote debug will work. If I change the line to

eventlet.monkey_patch(os=False, thread=False)

The remote debug will also work.

But I can not do that, because this will break some other logic.(I am trying to remote debug openstack neutron. The above code is just a sample to describe my question)

Also I have done something after google this issue, I will paste them here although they are not fixing my issue.

1. In PyCharm do below setting

setting -> Build,Extension,Deployment -> Python Debug -> Gevent Compatible (Check)

2. In PyCharm do below change

Edit the file 
C:\Program Files (x86)\JetBrains\PyCharm 2016.1.4\helpers\pydev_pydevd_bundle\pydevd_constants.py

Replace SUPPORT_GEVENT=False to SUPPORT_GEVENT=True

I know this is a PyCharm issue or Pydevd issue. I already post this in PyCharm community not getting reply yet. So I guess I can try here. Please give some advice if you know about it.

Kramer Li
  • 2,284
  • 5
  • 27
  • 55

1 Answers1

1

Can't help with Pydevd, but there's interactive interpreter backdoor in Eventlet, which allows you to connect and execute any code to analyse state of the system.

eventlet.monkey_patch()
# add one line
eventlet.spawn(backdoor.backdoor_server, eventlet.listen(('localhost', 3000)))

Connect with your favourite telnet client.

http://eventlet.net/doc/modules/backdoor.html

Also, import ipdb ; ipdb.set_trace() has always worked wonders for me.

temoto
  • 5,394
  • 3
  • 34
  • 50
  • Using eventlet.monkey_patch() stops me being able to type in the ipdb console, how did you get around this? – steve Nov 28 '16 at 10:58