Skip to main content

Downloads Downloads Coverage Status Lines of code Hits-of-Code Test-Package Python versions PyPI version Checked with mypy Ruff DeepWiki

logo

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cantok-0.0.43.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cantok-0.0.43-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file cantok-0.0.43.tar.gz.

File metadata

  • Download URL: cantok-0.0.43.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for cantok-0.0.43.tar.gz
Algorithm Hash digest
SHA256 e40e16b4bfcbd5dcbdc036cac16ff64bb753a89b378837ec8a8b7ca90bc953d9
MD5 9ee8cb996667e9fede941aee41b365c8
BLAKE2b-256 ac67d7ca148e312ca5b624d3caf7185a8f7760a694e1c9597b2850f5dd635392

See more details on using hashes here.

Provenance

The following attestation bundles were made for cantok-0.0.43.tar.gz:

Publisher: release.yml on mutating/cantok

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cantok-0.0.43-py3-none-any.whl.

File metadata

  • Download URL: cantok-0.0.43-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for cantok-0.0.43-py3-none-any.whl
Algorithm Hash digest
SHA256 8f5288fce95acc1c359264fbde27146e91f08c599bf700884b7c4f35c9328c28
MD5 969de396cc65c8cc59a45580a9f85a11
BLAKE2b-256 57ceb7287569531994f3e1513b72c583dbd4db97bcec63c63183c8d3393049c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for cantok-0.0.43-py3-none-any.whl:

Publisher: release.yml on mutating/cantok

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.43 This release

2 files

0.0.42

2 files

0.0.41

2 files

0.0.40

2 files

0.0.39

2 files

0.0.38

2 files

0.0.37

2 files

0.0.36

2 files

0.0.35

2 files

0.0.34

2 files

0.0.33

2 files

0.0.32

2 files

0.0.31

2 files

0.0.30

2 files

0.0.29

2 files

0.0.28

2 files

0.0.27

2 files

0.0.26

2 files

0.0.25

2 files

0.0.24

2 files

0.0.23

2 files

0.0.22

2 files

0.0.21

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

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