4

I'm writing an Python Bottle application (Python 2.7.2 and Bottle 0.10.9) and developing it in the WingIDE (3.2.8-1) Professional for Linux. This all works well, except when I want to debug the Bottle application. I have it running in standalone mode within WingIDE, but it won't stop at any of my break points in the code, even if I set Bottle.debug(False). Does anyone have any suggestions/ideas about how I can setup Bottle so it will stop on breakpoints within WingIDE?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
writes_on
  • 1,735
  • 2
  • 22
  • 35

2 Answers2

4

If you have the reloader set to true bottle starts a subproccess for the actual app. In Wing you need to turn off the reloader, then it should work.

run(reloader=False).  

But you will have to restart the app in wing every time you make changes.

i_4_got
  • 918
  • 9
  • 10
  • That was the problem, setting reloader=False allows me to debug within WingIDE. And you're correct, I have to restart the app every time I make a change. Not a big deal since I'm still building the application. Thanks for the help!! – writes_on Dec 04 '12 at 18:28
  • @writes_on No Problem, I use Wing IDE and bottle frequently. Same as the webhelpers question, I would appreciate if you could accept the answer. People will be more willing to answer your questions if your acceptance rating is higher. Happy Programming! – i_4_got Dec 04 '12 at 18:51
  • The situation is identical with IntelliJ Python plugin - breakpoints don't work if the app is run with reloader=True. – grudolf Mar 26 '13 at 20:25
3

Are you debugging under WSGI using wingdbstub.py or launching bottle from the IDE? I'm not that familiar with bottle but a common problem is a web framework's reload mechanism running code in a sub-process that is not debugged. I'm not certain bottle would do that under WSGI, however, but printing the process id at time of importing wingdbstub (or startup if launching from the IDE) and again at the line where the breakpoint is missed would rule this in our out. The "reloader" arg for Bottle.__init__ may be relevant here. If set to True, try setting it to False when debugging under Wing.

Another thing to try is to raise an exception on purpose where the breakpoint is (like "assert 0, 'test exception'" and see if this exception is reported in Wing's debugger in the Exceptions tool and if so whether Wing also manages to open the source code. If bottle is running code in a way that doesn't make it possible to find the source code then this would still stop on the assertion (Wing's debugger stops on all assertions by default even if the host code handles the exception) but it would fail to show the debug file and would put up a message in the status area (at bottle of IDE screen and in the Messages tool) that indicates the file name the debug process specified. Depending on this it may be possible to fix the problem (but would require modifying Bottle if the file name is something like "".

BTW, to insert code that is only run under Wing's debugger us something like this:

import os if 'WINGDB_ACTIVE' in os.environ: # code here

If this doesn't help please email support at wingware dot com.

Wingware
  • 896
  • 5
  • 12
  • You totally get it by giving your support here on SO. – Prof. Falken Dec 03 '12 at 16:38
  • You are also correct, the reloader=True flag caused the app to run in a sub-process not debugged by Wing. Setting reloader=False allows me to catch breakpoints. Thanks! – writes_on Dec 04 '12 at 18:30