{"id":19427136,"url":"https://github.com/anergictcell/siginfo","last_synced_at":"2025-02-25T05:17:52.107Z","repository":{"id":57467064,"uuid":"170180035","full_name":"anergictcell/siginfo","owner":"anergictcell","description":"Python library to inspect/debug programs using SIGUSR signals","archived":false,"fork":false,"pushed_at":"2023-09-30T13:06:07.000Z","size":41,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T09:09:05.824Z","etag":null,"topics":["python","python-library","signal-processing"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anergictcell.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-11T18:31:04.000Z","updated_at":"2023-09-30T12:50:56.000Z","dependencies_parsed_at":"2024-11-10T18:02:55.502Z","dependency_job_id":null,"html_url":"https://github.com/anergictcell/siginfo","commit_stats":{"total_commits":19,"total_committers":2,"mean_commits":9.5,"dds":"0.42105263157894735","last_synced_commit":"d3c2690574c12ba62cc8cd8867c4ec79004dc4bf"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anergictcell%2Fsiginfo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anergictcell%2Fsiginfo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anergictcell%2Fsiginfo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anergictcell%2Fsiginfo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anergictcell","download_url":"https://codeload.github.com/anergictcell/siginfo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240605844,"owners_count":19827985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","python-library","signal-processing"],"created_at":"2024-11-10T14:10:33.340Z","updated_at":"2025-02-25T05:17:52.074Z","avatar_url":"https://github.com/anergictcell.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"*******\nsiginfo\n*******\n\n``siginfo`` is a small Python module to conveniently get status or debug info from running Python processes.\n\n\n``siginfo`` listens for ``SIGUSR1`` or ``SIGUSR2`` [#f1]_ signals and prints info about the current callstack, local variables etc.\n\n\nUse cases\n=========\nYou have long running Python processes and want to check in on progress, but don't want to print the progress all the time.\nThis is especially useful for I/O heavy operations.\n\nImagine you're reading in a large file and work on it line by line. Instead of printing the line-number in regular intervals, you can simply send a SIGUSR command from another shell session and see the current callstack or start an interactive debugger. \n\n\nHow to\n======\n\nSimply add the following two lines:\n\n.. code:: python\n\n    from siginfo import SiginfoBasic\n    SiginfoBasic()\n\nto your python script. Once your application is running, you can always check the current callstack from another shell session by sending a SIGUSR signal.\n\n.. code:: bash\n\n    kill -SIGUSR1 ${pid}\n\n\nIt will now print the current callstack with basic information about all local variables to stdout (or a predefined file).\n\n.. code-block:: bash\n\n    ========================================================================================================================\n    LEVEL       0\n    METHOD      read_lines\n    LINE NUMBER:    33\n    ------------------------------------------------------------------------------------------------------------------------\n    LOCALS\n    VARIABLE | TYPE            | VALUE\n    i        | int             | 1\n    fh       | TextIOWrapper   | \u003c_io.TextIOWrapper name='many_rows.txt' mode='r' encoding='UTF-8'\u003e\n    b        | int             | 15\n    a        | int             | 12\n    line     | str             | Row 1\n\n    ------------------------------------------------------------------------------------------------------------------------\n    SCOPE   \u003ccode object read_lines at 0x108c30c90, file \"long_script.py\", line 24\u003e\n    CALLER  \u003ccode object main2 at 0x108c309c0, file \"long_script.py\", line 21\u003e\n    ========================================================================================================================\n\n    ========================================================================================================================\n    LEVEL       1\n    METHOD      main2\n    LINE NUMBER:    22\n    ------------------------------------------------------------------------------------------------------------------------\n    LOCALS\n    VARIABLE    | TYPE    | VALUE\n    ------------------------------------------------------------------------------------------------------------------------\n    SCOPE   \u003ccode object main2 at 0x108c309c0, file \"long_script.py\", line 21\u003e\n    CALLER  \u003ccode object main at 0x108c30ed0, file \"long_script.py\", line 18\u003e\n    ========================================================================================================================\n\n    ...\n\n\nInstallation\n============\nYou can install siginfo via pip\n\n.. code:: bash\n\n    pip install siginfo\n\n\nUsage\n=====\n\nInclude ``siginfo`` in your python script\n\n.. code:: python\n\n    import siginfo\n\n\nInitialize SignInfo Class\n-------------------------\n\n.. code:: python\n\n    siginfo.SiginfoBasic()\n\n\n\nBasic overview\n==============\n\n``siginfo`` contains the following classes:\n\n- ``SiginfoBasic`` Print info about the current stack (and caller stacks). Regular execution continues automatically.\n- ``SigInfoPDB`` Open the ``PDB`` debugger. Pauses script execution until debugger is exited.\n- ``SigInfoSingle`` Print the value of a single variable of the current scope. Continues regular execution automatically.\n\n\nInitiating the class\n--------------------\n\nAll class allow the following arguments:\n\n- ``info`` Listen for ``SIGNFO`` (Default: ``True``) (only on Mac and BSD)\n- ``usr1`` Listen for ``SIGUSR1`` (Default: ``True``)\n- ``usr2`` Listen for ``SIGUSR2`` (Default: ``False``)\n- ``output`` Where to write the output to (Default: ``sys.stdout``). Can be anything that offers a ``write`` function.\n\n\n.. code:: python\n\n    from siginfo import SiginfoBasic\n    SiginfoBasic(info=True, usr1=False)  # listen only for SIGINFO\n    SiginfoBasic(info=False, usr=True)  # listen only for SIGUSR1\n    SiginfoBasic(output=open('mylog.log', 'a'))  # Write call stack output to a log file\n\n\n\n``signinfo`` class instance attributes\n--------------------------------------\n\n- ``COLUMNS``: Maximum width of the Terminal (or max number of rows per line in an output file) (Default: current tty columns - 20; Fallback to 80 if determination isn't possible)\n- ``MAX_LEVELS``: Number of stack frames to print (Default: 1 [only the current one])\n- ``OUTPUT``: Same as ``output`` argument to the constructor function. Defines where to write the output to (Default: ``sys.stdout``)\n\n.. code:: python\n\n    from siginfo import SiginfoBasic\n    info_handler = SiginfoBasic()\n\n    info_handler.COLUMNS = 200  # Format output to match 200 columns\n    info_handler.MAX_LEVELS = 4  # Print the current frame + 3 parent frames\n    info_handler.OUTPUT = open('mylog.log', 'a')  # write the output to mylog.log\n\n\nAPI docs\n========\nFor a more detailed API description, check out `the full documentation`_ \n\n.. _the full documentation: https://esbme.com/siginfo/docs/\n\n\n.. rubric:: Footnotes\n\n.. [#f1] In addition, on MacOS or BSD system, the ``SIGINFO`` signal can be used as well.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanergictcell%2Fsiginfo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanergictcell%2Fsiginfo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanergictcell%2Fsiginfo/lists"}