Krzysztof Żuraw blog

Debugging python code with wdb

October 01, 2017

While I was on PyConPL conference last year I heard about interesting debugger called wdb. Since then I don’t have much chance to find out how it is to work with the tool. Yet I decided to write a quick blog post about it. Let’s get started!

What exactly is wdb? From its github :

wdb is a full featured web debugger based on a client-server architecture.

It means that I can debug my python based applications inside my browser even from the different computer. It’s using web sockets under the hood. How can I debug for example django application?

Let’s use my django application from Django Nginx blog series: repo. As it’s in docker I only need to add an entry in docker-compose:

        - wdb
    image: kozea/wdb-server
        - "1984:1984"

The last thing is to add wdb support to

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")

application = get_wsgi_application()

from wdb.ext import WdbMiddleware
application = WdbMiddleware(application)

Let’s see how it works:

How wdb works

I have to say that I’m really impressed by this project - awesome job! If you want to have code example go here.

That’s all for today!

Want to get blog posts via email?

Powered by Buttondown.

Krzysztof Żuraw

Written by Krzysztof Żuraw who lives and works in Wrocław. You can find more on about page and subscribe to rss feed.