Skip to main content

Assorted debugging facilities.

Latest release 20221118: stack_dump: cope when cs.logutils.setup_logging not run yet.

Function DEBUG(f, force=False)

Decorator to wrap functions in timing and value debuggers.

Function debug_object_shell(o, prompt=None)

Interactive prompt for inspecting variables.

Class DebuggingLock(DebugWrapper, types.SimpleNamespace)

Wrapper class for threading.Lock to trace creation and use.

cs.threads.Lock() returns one of these in debug mode or a raw threading.Lock otherwise.

Class DebuggingRLock(DebugWrapper, types.SimpleNamespace)

Wrapper class for threading.RLock to trace creation and use.

cs.threads.RLock() returns on of these in debug mode or a raw threading.RLock otherwise.

Class DebugShell(cmd.Cmd)

An interactive prompt for python statements, attached to /dev/tty by default.

Class DebugWrapper(types.SimpleNamespace)

Base class for classes presenting debugging wrappers.

Function DF(func, *a, **kw)

Wrapper for a function call to debug its use.

This requires rewriting the call from f(*a,*kw) to DF(f,*a,**kw). Alternatively one could rewrite as DEBUG(f)(*a,**kw).

Function Lock()

Factory function: if cs.logutils.loginfo.level<=logging.DEBUG then return a DebuggingLock, otherwise a threading.Lock.

Function openfiles(substr=None, pid=None)

Run lsof(8) against process pid returning paths of open files whose paths contain substr.

Parameters:

  • substr: default substring to select by; default returns all paths.
  • pid: process to examine; default from os.getpid().

Function RLock()

Factory function: if cs.logutils.loginfo.level<=logging.DEBUG then return a DebuggingRLock, otherwise a threading.RLock.

Function selftest(module_name, defaultTest=None, argv=None)

Called by my unit tests.

Function stack_dump(stack=None, limit=None, logger=None, log_level=None)

Dump a stack trace to a logger.

Parameters:

  • stack: a stack list as returned by traceback.extract_stack. If missing or None, use the result of traceback.extract_stack().
  • limit: a limit to the number of stack entries to dump. If missing or None, dump all entries.
  • logger: a logger.Logger ducktype or the name of a logger. If missing or None, obtain a logger from logging.getLogger().
  • log_level: the logging level for the dump. If missing or None, use cs.logutils.loginfo.level.

Function thread_dump(Ts=None, fp=None)

Write thread identifiers and stack traces to the file fp.

Parameters:

  • Ts: the Threads to dump; if unspecified use threading.enumerate().
  • fp: the file to which to write; if unspecified use sys.stderr.

Class TimingOutLock

A Lock replacement which times out, used for locating deadlock points.

Function trace_caller(func)

Decorator to report the caller of a function when called.

Class TraceSuite

Context manager to trace start and end of a code suite.

Release Log

Release 20221118: stack_dump: cope when cs.logutils.setup_logging not run yet.

Release 20211208: @trace moved to cs.pyfunc, other minor changes.

Release 20200318: Remove use of cs.obj.O, universally supplanted by types.SimpleNamespace.

Release 20181231:

  • New TimingOutLock for locating deadlock points, grew from debugging cs.vt.index.
  • Other minor changes.

Release 20171231:

  • Update imports for recentchanges.
  • New context manager TraceSuite to trace start and end of a code suite.

Release 20160918: selftest(): fix parameter ordering to match unittest.

Release 20160828: Update metadata with "install_requires" instead of "requires".

Release 20160827:

  • New openfiles() to return selected pathnames of open files via lsof(8).
  • New selftest() to invoke unittests with benefits.
  • DebugShell, a cmd.Cmd subclass for debugging - current use case calls this with self.dict in a test case tearDwon.
  • debug_object_shell: convenience wrapper for DebugShell to call it on an object's attributes.

Release 20150116: PyPI prep.

Metadata

Release files for cs-debug 20221118

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cs-debug 20221118
File Size Uploaded Provenance Actions
cs.debug-20221118.tar.gz 8.2 kB Without provenance Details for cs.debug-20221118.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cs-debug 20221118
File Interpreter ABI Platform Actions
cs.debug-20221118-py3-none-any.whl Python 3 none any Details for cs.debug-20221118-py3-none-any.whl

Total release size: 16.2 kB

Release files / cs.debug-20221118.tar.gz

Download URL cs.debug-20221118.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
955b3656a4206df11d3cfde7ea286dea24cbfe3403afb5793f01030f57bff596
BLAKE2b-256 checksum
How to use checksums
a66860190967e81846bac536bde9206521c12b0eb13c348a1f2e19b5a4545c3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / cs.debug-20221118-py3-none-any.whl

Download URL cs.debug-20221118-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce6a9fba4baa5d38eca19f584685e7f04e116ba40b108c0d4c052c1a7155ff63
BLAKE2b-256 checksum
How to use checksums
cb94f4976c83dfda37032120d98564e58512d96c7cc12a3be8ae30f28dd4a5c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for cs-debug 20221118

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page