This repository has been archived on 2023-06-09. You can view files and clone it, but cannot push or open issues or pull requests.
jarvis-server/jarvis/skills/background_tasks.py

29 lines
510 B
Python
Raw Normal View History

from threading import Thread
running_tasks = dict()
def add_task(key, thread: Thread):
running_tasks[key] = thread
running_tasks[key].start()
def remove_task(key):
del running_tasks[key]
def contains_task(key):
if key in running_tasks.keys():
return True
return False
def get_tasks_starting_with_in_name(starts_with):
matching = []
for key in running_tasks.keys():
if str(key).startswith(starts_with):
matching.append(key)
return matching