When pdb Fails in Production
Your Flask API is timing out. Not consistently—just on certain requests. You add breakpoint() and restart the server, but by the time you hit the breakpoint, the problematic request pattern has already passed. You try logging, but the issue vanishes when you add enough logs to catch it. This is where traditional Python debugging tools stop being useful.
I spent months debugging production issues with pdb, logging, and the occasional print() statement before realizing these tools weren't built for the constraints I was working under. You can't pause a live server. You can't restart a process that takes 10 minutes to warm up. And you definitely can't add logging fast enough when the bug only appears under specific load patterns.
That's when I started using gdb with Python extensions and py-spy. These aren't beginner-friendly tools—they require understanding how Python's interpreter works at the C level. But they let you attach to running processes without modifying code or restarting anything. Here's what actually works in production.
Continue reading the full article on TildAlice

Top comments (0)