A interruptible list
Build a list from a iterable, interruptible by KeyboardInterrupt (SIGINT), and monitorable by SIGUSR1 and SIGUSR2.
The function interruptible_list act as list() constructor, and build a list from
an iterable, except:
- When a SIGINT (CTRL-C, KeyboardInterrupt) is received, the construction is stopped, and the current list is returned.
- When a SIGUSR1 is received, the last item is pickled in a file or a callback is called on the last item, and the construction of the list continues.
- When a SIGUSR2 is received, the whole current list is pickled in an file or a callback is called on the whole current list, and the construction of the list continues.
Examples
All examples are illustrated with a slow version of range(60).
import time
def mygen():
for i in range(60):
time.sleep(1)
yield i
-
Basic interruptible list:
from interruptible_list import interruptible_list L = interruptible_list(mygen())
-
With callback on
SIGUSR1to display the last item onstderrimport sys from interruptible_list import interruptible_list def mycallback(x): print(x, file=sys.stderr) L = interruptible_list(mygen(), callback_last=mycallback)
-
With callback on
SIGUSR2to display the mean on the current list onstderr:import sys from interruptible_list import interruptible_list def mycallback_mean(thelist): mean = sum(thelist)/len(thelist) print(mean, file=sys.stderr) L = interruptible_list(mygen(), callback_whole=mycallback_mean)
-
With save on
SIGUSR1andSIGUSR2. Last item (USR1) or the whole current list (USR2) is pickled when the signal is received.from interruptible_list import interruptible_list L = interruptible_list(mygen(), save_last=True, save_whole=True)
Metadata
Release files for interruptible-list 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| interruptible_list-0.2.tar.gz | 5.0 kB | Without provenance | Details for interruptible_list-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| interruptible_list-0.2-py3-none-any.whl | Python 3 | none | any | Details for interruptible_list-0.2-py3-none-any.whl |
Total release size: 15.9 kB
Release files / interruptible_list-0.2.tar.gz
| Download URL | interruptible_list-0.2.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c50b1f3f22ac2fa0e12ce80d6c27688d7be217b0fb28e02fb70b8a008a73b7a
|
|
BLAKE2b-256 checksum How to use checksums |
d41ae9ce5a4065516f2ece0f727b7f26ff862c3522412817bd832f91d7ab334a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
|
Release files / interruptible_list-0.2-py3-none-any.whl
| Download URL | interruptible_list-0.2-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
67ca84046775d64ea257e2f8a2f339a8f2ba1aaba3fb31c70205e490e2e1edd5
|
|
BLAKE2b-256 checksum How to use checksums |
56bd3a7299e0ee169184f6d4cc98ffc38742d0332d88c5e9c4c39f6f7f276500
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
|
Security for interruptible-list 0.2
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.