Skip to main content

Installation

pip install cancelable

Usage

Without the normal time package:

Sleep

from cancelable import time
import threading

def count():
  i = 1
  while True:
    time.sleep(1)
    print(i)
    i += 1

threading._start_new_thread(count, ())

input("Click enter to cancel counting\n")

time.cancel()

With the normal time package:

from cancelable import time as cancelableTime
import threading

def count():
  i = 1
  while True:
    cancelableTime.sleep(1)
    print(i)
    i += 1

threading._start_new_thread(count, ())

input("Click enter to cancel counting\n")

cancelableTime.cancel()

Input

from cancelable import time, input, cancelInput
import threading

name = ""
def ask():
  global name
  name = input("Your name: ")
  time.cancel()

threading._start_new_thread(ask, ())

time.sleep(5)
cancelInput()

print(name)

To do

Add more functions such as input()

Metadata

Release files for cancelable 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cancelable 0.0.4
File Size Uploaded
cancelable-0.0.4.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cancelable 0.0.4
File Interpreter ABI Platform
cancelable-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / cancelable-0.0.4.tar.gz

Download URL cancelable-0.0.4.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f1116caf69f5bb86af0591f643f00f2d2efdb722632dab5a91c3ac65f6a1772f
BLAKE2b-256 checksum
How to use checksums
80d99f476d2cf543db259ef98736bb44cee7ed210cb7bac13f27769989938e0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / cancelable-0.0.4-py3-none-any.whl

Download URL cancelable-0.0.4-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ceac8ce70c03c194e750cb68abdbe576a6611584f0f591fb027ef31337924cfa
BLAKE2b-256 checksum
How to use checksums
c97c406349c4ecc2ff8d6175e0ce39a2fe3d5b344c0f21b0f997561166ff37c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release 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