Added propagation of the program stop event

This commit is contained in:
2022-09-01 22:07:14 +02:00
parent 69db2dbbee
commit 7002439532
4 changed files with 34 additions and 12 deletions

View File

@@ -14,6 +14,7 @@ class AsyncTask(threading.Thread):
@since 2022-09-01
"""
# Variables
__stop = None
__callback = None
__args: list = None
@@ -30,6 +31,7 @@ class AsyncTask(threading.Thread):
:args: -> Argument to pass to the function when executing it.
"""
super().__init__()
self.__stop = threading.Event()
self.__callback = callback
self.__args = args
@@ -37,4 +39,8 @@ class AsyncTask(threading.Thread):
"""
[!] : This function should not be used! Start the task with {AsyncTask.start()}!
"""
self.__callback(*self.__args)
self.__callback(*self.__args)
def stop(self) -> None:
# TODO
self.__stop.set()