2

I'm trying to debug a python hug API with pdb.

The regular hug api is started with: hug -f api.py

You can start pdb from the command line via python interpreter using:

python -m pdb api.py

Where api.py contains hug routes, directives etc. api.py however needs to be run with hug -f api.py which doesn't accept -m pdb.

eg: hug -m pdb -f api.py doesn't work.

I also tried creating a debug.py file and import api.py into it with debugging started. But it doesn't register the routes in api.py.

import pdb
from api import *

@hug.startup()
def startup(args):
    """Starts api and debugging"""
    pdb.set_trace()

The hug server starts ok, but without any routes defined in api.py.

At the moment I'm resorting to having to put pdb.set_trace() directly into one of the routes in api.py. This works but is tedious. Ideally there should be a way to start api.py with hug and pdb debugging and set breakpoints dynamically without restarting hug.

bucabay
  • 5,235
  • 2
  • 26
  • 37

1 Answers1

0

This happens because the auto re-loader can not handle with debugger.

Use --manual_reload option when start app.

More about this issue here

Mauro Baraldi
  • 6,346
  • 2
  • 32
  • 43