Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gevent monkey-patching and breakpoints

I have been playing with Gevent, and I like it a lot. However I have run into a problem. Breakpoint are not being hit, and debugging doesn't work (using both Visual Studio Python Tools and Eclipse PyDev). This happens after monkey.patch_all() is called.

This is a big problem for me, and unfortunately this is a blocker for the use of gevent. I have found a few threads that seem to indicate that gevent breaks debugging, but I would imagine there is a solution for that.

Does anyone know how to make debugging and breakpoints work with gevent and monkey patching?

like image 444
Flavien Avatar asked Jul 15 '12 20:07

Flavien


People also ask

What is monkey patching gevent?

monkey – Make the standard library cooperative. Make the standard library cooperative. The primary purpose of this module is to carefully patch, in place, portions of the standard library with gevent-friendly functions that behave in the same way as the original (at least as closely as possible).

What does monkey Patch_all () do?

Monkey patching is a technique used to dynamically update the behavior of a piece of code at run-time.

Why is it called monkey patching?

The term monkey patch seems to have come from an earlier term, guerrilla patch, which referred to changing code sneakily – and possibly incompatibly with other such patches – at runtime. The word guerrilla, nearly homophonous with gorilla, became monkey, possibly to make the patch sound less intimidating.

What the heck is gevent?

gevent is a coroutine-based cooperative multitasking python framework that relies on monkey patching to make all code cooperative. Gevent actually draws its lineage from Eve Online which was implemented using Stackless Python which eventually evolved into eventlet which inspired gevent.


1 Answers

PyCharm IDE solves the problem. It supports gevent code debugging after you set a configuration flag: http://blog.jetbrains.com/pycharm/2012/08/gevent-debug-support/.

Unfortunately, at the moment I don't know a free tool capable of debugging gevent.

UPD: THERE IS! Now there is a community version of PyCharm.

like image 58
Ellioh Avatar answered Sep 19 '22 18:09

Ellioh