Implementation of the "Cancellation Token" pattern
Project description
Cancellation Token is a pattern that allows us to cancel calculations that we no longer need. It is implemented out of the box in many programming languages, for example in C# and in Go. However, there was still no sane implementation in Python, until the cantok library appeared.
Quick start
Install it:
pip install cantok
And use:
from random import randint
from cantok import ConditionToken, CounterToken, TimeoutToken
token = ConditionToken(lambda: randint(1, 100_000) == 1984) + CounterToken(400_000, direct=False) + TimeoutToken(1)
counter = 0
while token:
counter += 1
print(counter)
Read more in the documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cantok-0.0.36.tar.gz.
File metadata
- Download URL: cantok-0.0.36.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1e60a7c436878b4f4b03422b7289a6c94f5bca7af76a9e5e587d9a6b4863823
|
|
| MD5 |
d16754243821899214df8d8a652d3897
|
|
| BLAKE2b-256 |
7b238d14eb79edc9f4a00379f1956720d84b94ada9d594ee36e06fb886d06b1c
|
Provenance
The following attestation bundles were made for cantok-0.0.36.tar.gz:
Publisher:
release.yml on pomponchik/cantok
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cantok-0.0.36.tar.gz -
Subject digest:
e1e60a7c436878b4f4b03422b7289a6c94f5bca7af76a9e5e587d9a6b4863823 - Sigstore transparency entry: 1203458960
- Sigstore integration time:
-
Permalink:
pomponchik/cantok@41ff38c17171ab518a2b3da8164d27ce280d56f8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pomponchik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ff38c17171ab518a2b3da8164d27ce280d56f8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cantok-0.0.36-py3-none-any.whl.
File metadata
- Download URL: cantok-0.0.36-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f3e29807547ad5b303a7d3195b9bde20cae4d027bcba0f78e84a425b0f070c7
|
|
| MD5 |
0f7bfc62b0587f48eff63c2b749d2887
|
|
| BLAKE2b-256 |
41f0931c0df6f7a5d5256e924c6a57ad86ebaa7500de3f8eb0d7d561401d7ef6
|
Provenance
The following attestation bundles were made for cantok-0.0.36-py3-none-any.whl:
Publisher:
release.yml on pomponchik/cantok
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cantok-0.0.36-py3-none-any.whl -
Subject digest:
9f3e29807547ad5b303a7d3195b9bde20cae4d027bcba0f78e84a425b0f070c7 - Sigstore transparency entry: 1203458963
- Sigstore integration time:
-
Permalink:
pomponchik/cantok@41ff38c17171ab518a2b3da8164d27ce280d56f8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pomponchik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ff38c17171ab518a2b3da8164d27ce280d56f8 -
Trigger Event:
push
-
Statement type: