setting breakpoints from within python

View: New views
2 Messages — Rating Filter:   Alert me  

setting breakpoints from within python

by Steve Howell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am wondering if there is a way to set a pydev breakpoint programatically within python code.  Obviously, I generally set breakpoints through pydev itself, but there are two cases where I'd like to do it programatically.  

The first case is to debug django templates--I want to emulate this snippet, but in pydev:

http://www.djangosnippets.org/snippets/1550/

The second case is where you might have a long running loop and only want to start tracing at the 999th operation or when some condition is met, etc.

A quick Google search didn't turn up anything here, but I suspect there are docs on this somewhere, so if anyone can give me a pointer, it would be much appreciated.

I've been using PyDev for a couple months now--it's very helpful!

Cheers,

Steve




------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Pydev-users mailing list
Pydev-users@...
https://lists.sourceforge.net/lists/listinfo/pydev-users

Re: setting breakpoints from within python

by Fabio Zadrozny-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I am wondering if there is a way to set a pydev breakpoint programatically within python code.  Obviously, I generally set breakpoints through pydev itself, but there are two cases where I'd like to do it programatically.

Yes, you can do that using:

import pydevd
pydevd.connected = True
pydevd.settrace()

Note that the pydevd.connected = True must be called only once (if you
don't do it, it'll think it has to connect to the remote debugger...
which is not what you want, unless you're actually using the remote
debugger). Note that you don't have to add pydevd to your pythonpath
(in a debug session it'll be there already without any special
setting).

Cheers,

Fabio

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Pydev-users mailing list
Pydev-users@...
https://lists.sourceforge.net/lists/listinfo/pydev-users