tasks
Class info¶
Classes¶
Name | Children | Inherits |
---|---|---|
PrioritizedTask llmling_agent.utils.tasks Task with priority and optional delay. |
||
TaskManagerMixin llmling_agent.utils.tasks Mixin for managing async tasks. |
|
🛈 DocStrings¶
PrioritizedTask
dataclass
¶
Task with priority and optional delay.
Source code in src/llmling_agent/utils/tasks.py
20 21 22 23 24 25 26 27 |
|
TaskManagerMixin
¶
Mixin for managing async tasks.
Provides utilities for: - Creating and tracking tasks - Fire-and-forget task execution - Running coroutines in sync context - Cleanup of pending tasks
Source code in src/llmling_agent/utils/tasks.py
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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
_run_scheduler
async
¶
_run_scheduler()
Run scheduled tasks when their time comes.
Source code in src/llmling_agent/utils/tasks.py
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 |
|
cleanup_tasks
async
¶
cleanup_tasks()
Wait for all pending tasks to complete.
Source code in src/llmling_agent/utils/tasks.py
175 176 177 178 179 |
|
complete_tasks
async
¶
complete_tasks(cancel: bool = False)
Wait for all pending tasks to complete.
Source code in src/llmling_agent/utils/tasks.py
181 182 183 184 185 186 187 |
|
create_task
¶
create_task(
coro: Coroutine[Any, Any, T],
*,
name: str | None = None,
priority: int = 0,
delay: timedelta | None = None,
) -> Task[T]
Create and track a new task with optional priority and delay.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coro
|
Coroutine[Any, Any, T]
|
Coroutine to run |
required |
name
|
str | None
|
Optional name for the task |
None
|
priority
|
int
|
Priority (lower = higher priority, default 0) |
0
|
delay
|
timedelta | None
|
Optional delay before execution |
None
|
Source code in src/llmling_agent/utils/tasks.py
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 |
|
fire_and_forget
¶
Run coroutine without waiting for result.
Source code in src/llmling_agent/utils/tasks.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
is_busy
¶
is_busy() -> bool
Check if we have any tasks pending.
Source code in src/llmling_agent/utils/tasks.py
171 172 173 |
|
run_background
¶
run_background(
coro: Coroutine[Any, Any, Any],
name: str | None = None,
priority: int = 0,
delay: timedelta | None = None,
)
Run a coroutine in the background and track it.
Source code in src/llmling_agent/utils/tasks.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
run_task_sync
¶
Run coroutine synchronously.
Source code in src/llmling_agent/utils/tasks.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|