p4utils.utils.task_scheduler module¶
-
class
p4utils.utils.task_scheduler.
ProcessType
[source]¶ Bases:
enum.IntEnum
Enum class that defines task types.
-
class
p4utils.utils.task_scheduler.
Task
(exe, start=0, duration=0, args=(), kwargs={})[source]¶ Bases:
object
Abstraction of a Task executed by the TaskServer.
Parameters: - exe (str or types.FunctionType) – executable to run (either a shell string command or a python function)
- start (int or float) – task absolute starting time (Unix time).
- duration (int or float) – task duration time in seconds (if duration is lower than or equal to 0, then the task has no time limitation)
- args (tuple or list) – positional arguments for the passed function
- kwargs (dict) – key-word arguments for the passed function
-
exitcode
[source]¶ Returns the exit code of the task.
Returns: exit code of the task. Return type: int Note
Returns None if the process has not yet terminated.
-
is_alive
()[source]¶ Returns whether the process is alive.
Returns: True if the process is alive, False otherwise. Return type: bool
-
pid
[source]¶ Returns the PID of the task.
Returns: PID of the running task. Return type: int Note
Returns None if the task has not been started yet.
-
schedule
(cond=None)[source]¶ Starts a new thread that orchestrate the execution of the task and stops it if duration expires.
Parameters: cond (threading.Condition) – condition to notify when self.thread is completed
-
setComm
(q)[source]¶ Set communication queue for the Task. The task will communicate its state putting items in the queue.
Parameters: - id (int) – task id used to communicate
- q (queue.Queue) – communication queue