librelist archives

« back to archive

Using Eclipse+PyDev for debugging Flask apps

Using Eclipse+PyDev for debugging Flask apps

From:
patrice
Date:
2011-05-12 @ 10:13
Hello,

I'm not a Python nor an Eclipse expert, but since I use both of them to
write small apps, I was annoyed by the fact I could not debug and watch
variables in a flask app. Pydev was losing the connection as soon as the
process was reloaded.

So I found this little trick that seems to be working :

if __name__ == '__main__':
    app.debug = False
    app.run()

If you just set app.debug as False, then there is no reload and then the
breakpoints seem to be working under Eclipse.

I hope that it will help someone :)

best regards

dolops

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
Charlie Evett
Date:
2011-05-12 @ 14:23
Thanks -- I was facing the same issue with IntelliJ, this was super helpful.

On Thu, May 12, 2011 at 6:13 AM, patrice <dolops@gmail.com> wrote:

> Hello,
>
> I'm not a Python nor an Eclipse expert, but since I use both of them to
> write small apps, I was annoyed by the fact I could not debug and watch
> variables in a flask app. Pydev was losing the connection as soon as the
> process was reloaded.
>
> So I found this little trick that seems to be working :
>
> if __name__ == '__main__':
>     app.debug = False
>     app.run()
>
> If you just set app.debug as False, then there is no reload and then the
> breakpoints seem to be working under Eclipse.
>
> I hope that it will help someone :)
>
> best regards
>
> dolops
>

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
Peter Ward
Date:
2011-05-12 @ 12:45
>>> from flask import Flask
>>> app = Flask(__name__)
>>> app.debug
False

Is there something magical about this I’m missing?
The tip seems just to be: don't turn on debug mode when using another
debugger (PyDev in this case).

On 12 May 2011 20:13, patrice <dolops@gmail.com> wrote:

> Hello,
>
> I'm not a Python nor an Eclipse expert, but since I use both of them to
> write small apps, I was annoyed by the fact I could not debug and watch
> variables in a flask app. Pydev was losing the connection as soon as the
> process was reloaded.
>
> So I found this little trick that seems to be working :
>
> if __name__ == '__main__':
>     app.debug = False
>     app.run()
>
> If you just set app.debug as False, then there is no reload and then the
> breakpoints seem to be working under Eclipse.
>
> I hope that it will help someone :)
>
> best regards
>
> dolops
>



-- 
Peter Ward
http://flowblok.id.au/
BIT III, Sydney University

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
Rob Mela
Date:
2011-05-12 @ 23:33
I don't think the problem is a debug on top of a debug.

My guess is that debug=True also triggers code reloading, and that the 
Python debugger (undersandably) will get confused if you pull the rug out 
from under it by reloading and recompiling the code that it's  debugging.


Den May 12, 2011 kl. 8:45 AM skrev Peter Ward:

>>> from flask import Flask
>>> app = Flask(__name__)
>>> app.debug
False

Is there something magical about this I’m missing?
The tip seems just to be: don't turn on debug mode when using another 
debugger (PyDev in this case).

On 12 May 2011 20:13, patrice <dolops@gmail.com<mailto:dolops@gmail.com>> wrote:
Hello,

I'm not a Python nor an Eclipse expert, but since I use both of them to 
write small apps, I was annoyed by the fact I could not debug and watch 
variables in a flask app. Pydev was losing the connection as soon as the 
process was reloaded.

So I found this little trick that seems to be working :

if __name__ == '__main__':
    app.debug = False
    app.run()

If you just set app.debug as False, then there is no reload and then the 
breakpoints seem to be working under Eclipse.

I hope that it will help someone :)

best regards

dolops



--
Peter Ward
http://flowblok.id.au/
BIT III, Sydney University

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
Rob Mela
Date:
2011-05-13 @ 00:49
duh.. maybe it is flask debug interfering -- trapping exceptions before 
the python debugger gets them.... I wonder...

Den May 12, 2011 kl. 7:33 PM skrev Rob Mela:

> I don't think the problem is a debug on top of a debug.
> 
> My guess is that debug=True also triggers code reloading, and that the 
Python debugger (undersandably) will get confused if you pull the rug out 
from under it by reloading and recompiling the code that it's  debugging.
> 

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
Chris Aliipule
Date:
2011-05-14 @ 01:57
Yes that's definitely it.

On Thu, May 12, 2011 at 2:49 PM, Rob Mela <rob@thinkingscreen.com> wrote:

> duh.. maybe it is flask debug interfering -- trapping exceptions before the
> python debugger gets them.... I wonder...
>
> Den May 12, 2011 kl. 7:33 PM skrev Rob Mela:
>
> > I don't think the problem is a debug on top of a debug.
> >
> > My guess is that debug=True also triggers code reloading, and that the
> Python debugger (undersandably) will get confused if you pull the rug out
> from under it by reloading and recompiling the code that it's  debugging.
> >
>
>

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
dolop
Date:
2011-05-12 @ 13:43
Hello,

no, nothing magical at all :) It's only I did not find this information
anywhere else, so I thought it could be of interest for others.

2011/5/12 Peter Ward <peteraward@gmail.com>

> >>> from flask import Flask
> >>> app = Flask(__name__)
> >>> app.debug
> False
>
> Is there something magical about this I’m missing?
> The tip seems just to be: don't turn on debug mode when using another
> debugger (PyDev in this case).
>
> [...]
> --
> Peter Ward
> http://flowblok.id.au/
> BIT III, Sydney University
>

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
Owen Marshall
Date:
2011-05-12 @ 13:31
On 05/12/2011 08:45 AM, Peter Ward wrote:
> Is there something magical about this I’m missing?
> The tip seems just to be: don't turn on debug mode when using another
> debugger (PyDev in this case).

To someone new to Flask, or Python in general, I can understand the
thinking -- "I want to debug my app; better set app.debug True".

A note in the documentation that indicates PyDev/other debuggers won't
work with the Flask debugger may prove helpful.

-- 
Owen Marshall
FacilityONE
omarshall@facilityone.com | (502) 805-2126

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
Ron DuPlain
Date:
2011-05-12 @ 17:08
On Thu, May 12, 2011 at 9:31 AM, Owen Marshall
<omarshall@facilityone.com> wrote:
> On 05/12/2011 08:45 AM, Peter Ward wrote:
>> Is there something magical about this I’m missing?
>> The tip seems just to be: don't turn on debug mode when using another
>> debugger (PyDev in this case).
>
> To someone new to Flask, or Python in general, I can understand the
> thinking -- "I want to debug my app; better set app.debug True".
>
> A note in the documentation that indicates PyDev/other debuggers won't
> work with the Flask debugger may prove helpful.

Done.
https://github.com/mitsuhiko/flask/commit/8b974eb35523fde507055a27f70484133bb21b79

This will be included in the next doc build.

-Ron

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
Alex
Date:
2011-05-12 @ 12:09
Why don't you add this to the snippets repository?
http://flask.pocoo.org/snippets/

Alex

On Thu, May 12, 2011 at 12:13 PM, patrice <dolops@gmail.com> wrote:
> Hello,
>
> I'm not a Python nor an Eclipse expert, but since I use both of them to
> write small apps, I was annoyed by the fact I could not debug and watch
> variables in a flask app. Pydev was losing the connection as soon as the
> process was reloaded.
>
> So I found this little trick that seems to be working :
>
> if __name__ == '__main__':
>     app.debug = False
>     app.run()
>
> If you just set app.debug as False, then there is no reload and then the
> breakpoints seem to be working under Eclipse.
>
> I hope that it will help someone :)
>
> best regards
>
> dolops
>

Re: [flask] Using Eclipse+PyDev for debugging Flask apps

From:
dolop
Date:
2011-05-12 @ 13:44
why not ? If majority agree that it is helpful ...

2011/5/12 Alex <thinkpragmatic@gmail.com>

> Why don't you add this to the snippets repository?
> http://flask.pocoo.org/snippets/
>
> Alex
>
>