|
cut 3.3.0
|
Provides a quick way to execute long running procedures. More...
Public Member Functions | |
| __new__ (Type cls, Callable fn, *args, **kwargs) | |
| Method that indicates how a new object for this class is created. | |
| __init__ (self, Callable fn, *args, **kwargs) | |
| Initializes a new Task, saving within its attributes the arguments passed. | |
| set_thread_pool (self, QThreadPool tp) | |
| Sets a custom QThreadPool in which the Task will be executed. | |
| QThreadPool | get_thread_pool (self) |
| Gets the currently used QThreadPool. | |
| int | start (self, bool with_qrunnable=True) |
| Starts the task, by requesting a common QThreadPool the execution of this object (which it accepts, as it is a QRunnable). | |
| run (self) | |
| Method that contains the logic that is pushed to the secondary thread. | |
Provides a quick way to execute long running procedures.
Provides a quick way to execute long running procedures in a separate thread. If the user may choose, they can set up connections to signals that are triggered in specific circumstances.
Inherits from QRunnable to handle task setup and wrap-up. Since QRunnable is not a QObject, it cannot have signals and slot: Thus, this is delegated to a WorkerSignals class that is owned by the WorkerIO.
In this example, it is shown how to use this class::
The start() method requests a common QThreadPool to execute this object.
Encapsulates a task to be executed, and executes it in another thread.
| task.task.Task.__init__ | ( | self, | |
| Callable | fn, | ||
| * | args, | ||
| ** | kwargs ) |
Initializes a new Task, saving within its attributes the arguments passed.
| [in] | fn | The function callback to run on this worker thread. Supplied args and kwargs will be passed through to the runner. |
| [in] | args | Arguments to pass to the callback function |
| [in] | kwargs | Keywords to pass to the callback function |
| task.task.Task.__new__ | ( | Type | cls, |
| Callable | fn, | ||
| * | args, | ||
| ** | kwargs ) |
Method that indicates how a new object for this class is created.
Implements singleton pattern for the ThreadPool. The first object created will store a "static" reference of the same object, and from then on the "static" reference is returned.
| QThreadPool task.task.Task.get_thread_pool | ( | self | ) |
Gets the currently used QThreadPool.
| task.task.Task.run | ( | self | ) |
Method that contains the logic that is pushed to the secondary thread.
This executes the method fn, with arguments args and kwargs, as indicated during initialization.
| task.task.Task.set_thread_pool | ( | self, | |
| QThreadPool | tp ) |
Sets a custom QThreadPool in which the Task will be executed.
Developer is responsible for its lifecycle.
| int task.task.Task.start | ( | self, | |
| bool | with_qrunnable = True ) |
Starts the task, by requesting a common QThreadPool the execution of this object (which it accepts, as it is a QRunnable).
If no threads are available, the task will be queued for execution.
| [in] | with_qrunnable | Uses QRunnable instead of taurus.Manager for task job execution. In particular, QRunnables offer more feedback capabilities. |