Skip to content

danielcoam/infinitythread

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

infinitythread

The thread that never sleeps.

Features

With InfinityThread you can

  • Run function Periodically inside a thread.
  • Keep running and Ignore function error.
  • Stop the thread.
  • Execute Cleanup Function when thread is stopped.

Usage

Basic Usage

from infinitythread import InfinityThread

my_thread = InfinityThread(target=my_func, interval=2)
my_thread.start()
# Run `my_func` every 2 seconds.

Advanced Usage

from infinitythread import InfinityThread

def my_func():
    print("I am running in intervals")
    raise Exception("Non affective exception")
    
def cleanup_function():
    print("Cleaning Up..")

my_thread = InfinityThread(target=my_func, interval=2, on_stop_func=cleanup_function, ignore_errors=True)
my_thread.start()
#  the thread keeps running like clockwork even with errors inside the target function.

my_thread.stop()
# When the thread stops the `cleanup_function` will be called.

Installation

$ pip install infinitythread

About

The thread that never sleeps.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages