A set of utilities for the python modules, threading and multiprocessing.
For a more detailed look at the executors (passing args,kwargs,and more) take a look at the thread_executor or multiprocessing_executor documentation.
import time
from combustive import thread_executor
@thread_executor()
def test():
# the code you want to run here
test.start() # Start the thread
time.sleep(10)
test.kill() # Kill it (This will throw an exception in the terminal)
import time
from combustive import multiprocessing_executor
@multiprocessing_executor()
def test():
# the code you want to run here
test.start() # Start the process
time.sleep(10)
test.terminate() # Terminate the process
Check the documentation of the background loop for a more detailed look at it and its arguments.
import time
from combustive import loop,LoopRunner
@loop(seconds=10,runner=LoopRunner.THREADING)
def test():
# The code you want to run every 10 seconds
test.start() # Start the background loop
time.sleep(10)
test.stop() # Stop it