A package that allows to cancel, certain functions that can be a pain, when working with threading.
Project description
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()
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
cancelable-0.0.4.tar.gz
(8.6 kB
view details)
Built Distribution
File details
Details for the file cancelable-0.0.4.tar.gz
.
File metadata
- Download URL: cancelable-0.0.4.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1116caf69f5bb86af0591f643f00f2d2efdb722632dab5a91c3ac65f6a1772f |
|
MD5 | 32cb457c9516af987ee76db955a474db |
|
BLAKE2b-256 | 80d99f476d2cf543db259ef98736bb44cee7ed210cb7bac13f27769989938e0a |
File details
Details for the file cancelable-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: cancelable-0.0.4-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceac8ce70c03c194e750cb68abdbe576a6611584f0f591fb027ef31337924cfa |
|
MD5 | bb063d2ad024c784e2773ff40f2a78e3 |
|
BLAKE2b-256 | c97c406349c4ecc2ff8d6175e0ce39a2fe3d5b344c0f21b0f997561166ff37c1 |