Skip to main content

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


Download files

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

Source Distribution

interval_repeat_decorator-0.10.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

interval_repeat_decorator-0.10-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file interval_repeat_decorator-0.10.tar.gz.

File metadata

File hashes

Hashes for interval_repeat_decorator-0.10.tar.gz
Algorithm Hash digest
SHA256 e188d51b3bb269f9d21f9e4d044302ea44c0a6060be40494118514bcebc2f037
MD5 f9fb6d1335a9cbe77dc623789d580a83
BLAKE2b-256 8ba41c19e7e04100101d2ef6c04d93d948523fbc796747d649ea396d25081228

See more details on using hashes here.

File details

Details for the file interval_repeat_decorator-0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for interval_repeat_decorator-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 f8607659af8ef1e92f4f1094aa24d449b47de3dcfe33bf32a16c11feb7a4691f
MD5 283ef499fba17ca724cf4a960055d441
BLAKE2b-256 15ac3db5025ca204946591e2a1c61aad675bbb4ea1e3040ae445ac4dd1f2c6be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page