Run code asynchronously to the main code execution
Project description
Run code asynchronously to the main code execution
pip install interval-repeat-decorator
from interval_repeat_decorator import repeat_action
from threading import Lock
lock = Lock()
@repeat_action(
print_exception=True,
exception_value="FTW",
break_on_exceptions=False,
interval=.1,
threadlock=lock,
kill_thread="ctrl+x",
number_of_executions=10,
)
def testest(number):
if number == 0:
print(number)
return True
elif number == 1:
print(number / 0)
return True
@repeat_action(
print_exception=True,
exception_value="FTW",
break_on_exceptions=False,
interval=.2,
threadlock=lock,
kill_thread="ctrl+y",
number_of_executions=5,
)
def testest2(number):
if number == 0:
print(number)
return True
elif number == 1:
print(number / 0)
return True
testex = testest(number=0)
testex2 = testest2(number=1)
print(f"{testex=}\n{testex2=}") #returns the first result only, but will keep on executing!
0
division by zero
testex=True
testex2='FTW'
0
division by zero
0
0
division by zero
0
0
division by zero
0
0
division by zero
0
0
testex
Out[3]: True
testex2
Out[4]: 'FTW'
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
File details
Details for the file interval_repeat_decorator-0.10.tar.gz
.
File metadata
- Download URL: interval_repeat_decorator-0.10.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e188d51b3bb269f9d21f9e4d044302ea44c0a6060be40494118514bcebc2f037 |
|
MD5 | f9fb6d1335a9cbe77dc623789d580a83 |
|
BLAKE2b-256 | 8ba41c19e7e04100101d2ef6c04d93d948523fbc796747d649ea396d25081228 |
File details
Details for the file interval_repeat_decorator-0.10-py3-none-any.whl
.
File metadata
- Download URL: interval_repeat_decorator-0.10-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8607659af8ef1e92f4f1094aa24d449b47de3dcfe33bf32a16c11feb7a4691f |
|
MD5 | 283ef499fba17ca724cf4a960055d441 |
|
BLAKE2b-256 | 15ac3db5025ca204946591e2a1c61aad675bbb4ea1e3040ae445ac4dd1f2c6be |