Package: web-pdb
Web-PDB is a web-interface for Python’s built-inPDBdebugger.
It allows to debug Python scripts remotely in a web-browser.FeaturesResponsive design based onBootstrap.Python syntax highlighting withPrism(“Okaida” theme).Supports all PDB features.Standard input and output can be redirected to the web-console
to interact with Python scripts remotely.Current filebox tracks current position in a file being executed.
Red line numbers indicate breakpoints, if any.GlobalsandLocalsboxes show local and global variables in the current scope.
Special variables that start and end with double underscores__are excluded
(you can always view them using PDB commands).Command history that stores up to 10 last unique PDB commands (accessed by arrow UP/DOWN keys).Web-PDB console in Chrome browserUsageInstall Web-PDB into your working Python environment:pip install web-pdbInsert the following line into your Python program at the point where you want
to start debugging:importweb_pdb;web_pdb.set_trace()Theset_trace()call will suspend your program and open a web-UI at the default port5555(port value can be changed). Enter in your browser’s address bar:http://<yourPython machine hostname orIP>:5555,
for examplehttp://monty-python:5555,
and you should see the web-UI like the one on the preceding screenshot.
Now you can use all PDB commands and features. AdditionalCurrent file,GlobalsandLocalsinformation boxes help you better track your program runtime state.Note: it is strongly recommended to work with the Web-PDB web-UI only in one browser session.
With more than one browser window accessing the web-UI it may display incorrect data in one or more
browser sessions.Subsequentset_trace()calls can be used as hardcoded breakpoints.Web-PDB is compatible with the newbreakpoint()function added in Python 3.7.
Set environment variablePYTHONBREAKPOINT="web_pdb.set_trace"to launch Web-PDB
withbreakpoint().Additionally, Web-PDB providescatch_post_mortemcontext manager that can catch
unhandled exceptions raised within its scope and automatically start PDB post-mortem debugging session.
For example:importweb_pdbwithweb_pdb.catch_post_mortem():# Some error-prone codeassertfoo==bar,'Oops!'For more detailed info about the Web-PDB API read docstrings in the./web_pdb/__init__.pyfile.TheinspectCommandWeb-PDB providesinspectoricommand that is not present in the original PDB.
This command outputs the list of object’s members along with their values.
Syntax:inspect <object_name>ori <object_name>.Special members with names enclosed in double underscores (__) are ignored.Considerations for Multithreading and Multiprocessing ProgramsMultithreadingWeb-PDB maintains one debugger instance that traces only one thread. You should not callset_trace()from different threads to avoid race conditions. Each thread needs to be debugged separately one at a time.MultiprocessingEach process can have its own debugger instance provided you callset_tracewith a different port value
for each process. This way you can debug each process in a separate browser tab/window.
To simplify this you can useset_trace(port=-1)to select a random port between 32768 and 65536.CompatibilityPython: 3.6+Browsers: Firefox, Chrome (all modern browsers should work)LicenseMIT, seeLICENSE.txt.The debugger icon made byFreepikfromwww.flaticon.comis licensed byCC 3.0 BY.