Added propagation of the program stop event
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user