Skip to content

Commit v0.3

kwmccabe edited this page Apr 17, 2018 · 14 revisions

v0.3 - Hello PythonDebugger


Files changed (3)

File docker-compose.yml MODIFIED

  • stdin_open : Open STDIN for debugger (--interactive , -i)
  • tty : Allocate a pseudo-TTY for debugger (--tty , -t)
         command: ./entrypoint.sh
         volumes:
             - ./web:/web
+        stdin_open: true
+        tty: true

File web/entrypoint.sh MODIFIED

  • --timeout : Extend worker lifetime 30 to 3600 to allow debugging session
     flaskapp:app \
     --bind :8000 \
     --workers 2 \
-    --timeout 3600 \
     --access-logfile logs/gunicorn-access.log \
     --error-logfile logs/gunicorn-error.log \
     --log-level info \
+    --timeout 3600 \
     --reload

File web/flaskapp.py MODIFIED

  • Create route /debug and method hello_debug() to test the PythonDebugger.
+# run 'docker ps' to get the flaskapp_web CONTAINER_ID
+# run 'docker attach CONTAINER_ID' to connect a terminal session
+# pdb.set_trace() will launch the debugger in the attached terminal
+# see https://docs.python.org/3.6/library/pdb.html?highlight=pdb#debugger-commands
+@app.route('/debug')
+def hello_debug():
+    import pdb; pdb.set_trace()
+    return "Hello Python Debugger"

Commit-v0.2 | Commit-v0.3 | Commit-v0.4

Clone this wiki locally