Multi Task Dispatch¶
Task
¶
Represents a task with dependencies and extra information.
Attributes:
Name | Type | Description |
---|---|---|
task_id |
The unique identifier for the task. |
|
dependencies |
A list of task IDs that must complete before this task can start. |
|
extra_info |
Any additional information associated with the task. |
Source code in repo_agent/multi_task_dispatch.py
TaskManager
¶
Manages a queue of tasks with dependencies and thread safety.
Attributes:
Name | Type | Description |
---|---|---|
task_dict |
Dict[int, Task]
|
Stores tasks, keyed by their IDs. |
lock |
Dict[int, Task]
|
A lock for thread-safe access to the task dictionary. |
next_id |
Dict[int, Task]
|
Generates unique IDs for new tasks. |
next_query_id |
Dict[int, Task]
|
Generates unique IDs for queries. |
Source code in repo_agent/multi_task_dispatch.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
all_success
property
¶
Checks if all tasks have finished. Returns True if no tasks remain, False otherwise.
Returns:
bool: True if the task dictionary is empty (all tasks successful), False otherwise.
__init__()
¶
Initializes the internal data structures for managing tasks and assigning unique identifiers.
This constructor initializes the internal data structures for managing tasks, including a dictionary to store tasks, a lock for thread safety, and IDs for new tasks and queries.
Returns:
Type | Description |
---|---|
None |
Source code in repo_agent/multi_task_dispatch.py
add_task(dependency_task_id, extra=None)
¶
Registers a new task, specifying its dependencies and optional additional information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dependency_task_id
|
List[int]
|
A list of IDs representing tasks that this task depends on. |
required |
extra
|
Optional additional information associated with the task. |
None
|
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The ID of the newly added task. |
Source code in repo_agent/multi_task_dispatch.py
get_next_task(process_id)
¶
Retrieves a ready-to-execute task for a specified process, considering dependencies and current status. Returns the task and its ID, or (None, -1) if no suitable task is found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
process_id
|
int
|
The ID of the process requesting a task. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing the task object and its ID. Returns (None, -1) if no task is available. |
Source code in repo_agent/multi_task_dispatch.py
mark_completed(task_id)
¶
Removes a task and updates any dependent tasks by removing it from their dependency lists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
int
|
The ID of the task to mark as completed. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in repo_agent/multi_task_dispatch.py
worker(task_manager, process_id, handler)
¶
Process that repeatedly fetches tasks and executes a provided handler on their associated data, until all tasks are successfully completed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_manager
|
The task manager object providing access to tasks. |
required | |
process_id
|
int
|
The ID of the current worker process. |
required |
handler
|
Callable
|
A callable that processes the extra information from a task. |
required |
Returns:
Type | Description |
---|---|
None |