84
loading...
This website collects cookies to deliver better user experience
pdb
is a powerful debugging tool that is included as a Python standard library. It can seriously speed up, our debug process, while resolving certain bugspdb
in your docker-compose
container will result in the following error....
...
return self.view_functions[rule.endpoint](**req.view_args)
File "/backend/app.py", line 25, in test_response
return response
File "/backend/app.py", line 25, in test_response
return response
File "/usr/local/lib/python3.9/bdb.py", line 88, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/local/lib/python3.9/bdb.py", line 113, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
pdb
in docker-compose
and not via docker run ...
, due to up
not being an interactive command by design.Flask
app in docker-compose
. https://github.com/zahaar/docker-pdb-interactive-debugging/
cd docker-pdb-interactive-debugging
docker-error
branchgit checkout docker-error
docker compose up
, or docker-compose up
if you are using old docker CLI versioncurl
command.curl -XGET 'http://localhost:5000/api/v1.0/the_answer'
pdb.DdbQuit
exception error:...
...
File "/usr/local/lib/python3.9/bdb.py", line 113, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
pdb
expects an open TTY, so let's add it to our compose
file...
...
ports:
- '5000:5000'
stdin_open: true # für pdb
tty: true # für pdb
git clone https://github.com/zahaar/docker-pdb-interactive-debugging/
, but on a main
branch this timedocker compose up
docker attach docker-interractive-debugging_api_1 // container name
Note we have this capability only after opening an TTY for our container
curl -XGET 'http://localhost:5000/api/v1.0/the_answer'
attached
you would see, pdb
waiting for commands.p true_response
to print the value of the variable true_response
c
to resume normal flowpdb
!!!Important Note: to stop attached window without stopping the main running container, you have to use,
escape sequence: CTRL + p -> CTRL + q
pdb
commands cheatsheet