roboglia.base.BaseThread¶
-
class
BaseThread
(name='THREAD', patience=1.0)[source]¶ Bases:
object
Implements a class that wraps a processing logic that is executed in a separate thread with the ability to pause / resume or fully stop the task.
The main processing should be implemented in the run method where the subclass should make sure that it checks periodically the status (paused or stopped) and behave appropriately. The run can be flanked by the setup and teardown methods where subclasses can implement logic needed before the main processing is started or finished.
This becomes very handy for loops that normally prepare the work, then run for an indefinite time, and later are closed when the owner signals.
- Parameters
name (str) – The name of the thread.
patience (float) – A duration in seconds that the main thread will wait for the background thread to finish setup activities and indicate that it is in
started
mode.
-
__init__
(name='THREAD', patience=1.0)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
property
name
¶ Returns the name of the thread.
-
property
started
¶ Indicates if the thread was started.
-
property
stopped
¶ Indicates if the thread was stopped.
-
property
running
¶ Indicates if the thread is running.
-
property
paused
¶ Indicates the thread was paused.