work on removing communicator
This commit is contained in:
parent
0b34aa7385
commit
4cf17ffe62
11 changed files with 52 additions and 60 deletions
|
@ -3,23 +3,24 @@ from typing import Iterable
|
|||
|
||||
from threading import Thread
|
||||
|
||||
from utils.bettersleep import better_sleep
|
||||
from time import sleep
|
||||
|
||||
|
||||
def _onionr_thread(func: Callable, args: Iterable,
|
||||
sleep: int, initial_sleep):
|
||||
better_sleep(initial_sleep)
|
||||
sleep_secs: int, initial_sleep):
|
||||
if initial_sleep:
|
||||
sleep(initial_sleep)
|
||||
while True:
|
||||
func(*args)
|
||||
better_sleep(sleep)
|
||||
sleep(sleep_secs)
|
||||
|
||||
|
||||
def add_onionr_thread(
|
||||
func: Callable, args: Iterable,
|
||||
sleep: int, initial_sleep: int = 5):
|
||||
sleep_secs: int, initial_sleep: int = 5):
|
||||
"""Spawn a new onionr thread that exits when the main thread does.
|
||||
|
||||
Runs in an infinite loop with sleep between calls
|
||||
Passes in an interable args and sleep variables"""
|
||||
Thread(target=_onionr_thread,
|
||||
args=(func, args, sleep, initial_sleep), daemon=True).start()
|
||||
args=(func, args, sleep_secs, initial_sleep), daemon=True).start()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue