psemdel/py-trading-bot

How to Debug?

Closed this issue · 1 comments

I'm using vscode in wsl2.

I set breakpoints at

1/ views.py
2/ telegram.py
3/ ib.py

it will break in 1 and 2 but not in 3. I know it's hitting ib.py because I do a print statement and send it to the console.

In case anybody is wondering, that's what I do to resolve the problem

In Launch.json, add celery in configuration. Then when you debug, select this "Django, Celery", and it should break on IB.py as well.

Of course, that will mean you need to do Redis-server before hand just like the start_bot.sh

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Django",
            "type": "debugpy",
            "request": "launch",
            "args": [
                "runserver", "--noreload", "--nothreading"
            ],
            "django": true,
            "autoStartBrowser": false,
            "program": "${workspaceFolder}/manage.py"
        },
        {
            "name": "Celery",
            "type": "debugpy",
            "request": "launch",
            "module": "celery",
            "console": "integratedTerminal",
            "args": [
                "-A",
                "trading_bot",
                "worker",
                "-l",
                "info",
            ]
        },
    ],
    "compounds": [
        {
            "name": "Django, Celery",
            "configurations": ["Python Debugger: Django", "Celery"]
        }
    ]    
}