semvec/pypi-packages huggingface dataset:
rasc 0.1.1
Generic key-value storage handling library

# rasc

For trashing your home directory (or `.config` or `.local/share`, for that
matter).

## Usage

Rasc can be used to handle config or other key-value data that can be
serialized into JSON or Python `dict`.  For config storage, one can use
directly or write a subclass of `storage.Configuration`.  For more generic
data, one can use `storage.Storage` instead.

Besides `json`, one can use different key-value formats by passing `load_func`,
`dump_func` and `ext` into the storage class to replace `json.load` and
`json.dump`.  For example, one can use [`tomllib.load`][tomllib] and
[`tomli_w.dump`][tomli_w], or write custom load/dump functions for SQLite.

[tomllib]: https://docs.python.org/3/library/tomllib.html
[tomli_w]: https://pypi.org/project/tomli-w/

Additionally, a simple CLI command parser is also included in `cli` for
demonstration purpose (with commands `rasc-demo` and `rasc-strict`),
but can also be used directly for your project.  Its usage can be seen in
`rasc/__init__.py` in the source code.

## Copying

This project is licensed under GPL version 3 only.  The license can be found in
`LICENSES/GPL-3.0-only.txt`.
preemptive-debugger 0.0.1
A simple method to interactively preempt a running script to run a debugger
Keywords: python,debugger,preemptive,interactive

# preemptive_debugger

A simple method to interactively preempt a running script to run a debugger

![preemptive_debugger](https://github.com/tylerlum/preemptive_debugger/assets/26510814/347fa015-0174-4e1d-b26f-a55b707ced47)

# Installing

Install:

```
pip install preemptive_debugger
```

# Usage

In one terminal, create a file called `test.py` with the following:

```
import preemptive_debugger

import time

for i in range(10_000):
    print(f"i = {i}")
    time.sleep(0.1)
```

Run this code with:

```
python3 test.py
```

In another terminal, run:

```
kill -SIGUSR1 $(pgrep -f "python3 test.py")
```

This will preempt the running script and start a debugger in the original terminal, which can be used to analyze what is happening. This is very useful when you have a script that is stuck or doing strange things. Without this package, if you want to see what is going on in the script, you would typically need to stop the script, modify the code, and try your best to reproduce the result (or wait a long time to have the issue come back up). With this package, adding just one line (`import preemptive_debugger`), you can easily start a debugger whenever you want to look into what is happening in a python program.

# Notes

I have tried some alternative methods to interactively choose when to start a debugger, but they didn't work well. Some pip packages I have tried:

- `keyboard`: Tried to start a debugger when a keyboard key was pressed, but I got this error which was very inconvenient:

```
ImportError: You must be root to use this library on linux.
```

- `pynput`: Tried to start a debugger when a keyboard key was pressed, but I realized this starts a new thread to run the handler. This does not allow me to properly analyze the state of the program I am interested in.

- `madbg`: Tried attaching to the script with `madbg attach <pid>`, but this only worked for very simple scripts. For any nontrivial script, I got this error:

```
pyinjector.api.LinuxInjectorPermissionError: Injector failed with -8 calling injector_attach: PTRACE_ATTACH error : Operation not permitted
Failed attaching to process due to permission error.
This is most likely due to ptrace scope limitations applied to the kernel for security purposes.
Possible solutions:
 - Rerun as root
 - Temporarily remove ptrace scope limitations usin
`echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope`
 - Persistently remove ptrace scope limitations by editing /etc/sysctl.d/10-ptrace.conf
More details can be found here: https://stackoverflow.com/q/19215177/2907819')
```

Running with `sudo`, I got this error:

```
pyinjector.api.InjectorError: Injector failed with -5 calling injector_inject: dlopen failed
```