service
dev_tool.services.task.service
log = logging.getLogger(__name__)
module-attribute
TaskManager
Source code in dev_tool/services/task/service.py
tasks = {}
instance-attribute
notification = CONTEXT.get_notification_service()
instance-attribute
__new__
set_posthook
A method that attaches a posthook to an existing task.
set_prehook
A method that attaches a prehook to an existing task.
register_watcher
A method that registers a progress watcher.
Parameters:
-
watcher(Callable[[TaskResult], None]) –The watcher function to register.
unregister_watcher
A method that unregisters a progress watcher.
Parameters:
-
watcher(Callable[[TaskResult], None]) –The watcher function to unregister.
Source code in dev_tool/services/task/service.py
submit
A method that submits a task for background execution.
Parameters:
-
task_type(TaskType) –The type of task to submit.
-
title(str) –The task title.
-
func(Callable[[], str]) –The function to execute.
-
completion_callback(Callable[[TaskResult], None] | None, default:None) –Optional callback for task completion.
-
parameters–Additional parameters for the task.
Returns:
-
str–The task ID.
Source code in dev_tool/services/task/service.py
cancel
A method that cancels a running or pending task.
Parameters:
-
task_id(str) –The ID of the task to cancel.
Returns:
-
bool–True if the task was cancelled, False if not found or already completed.
Source code in dev_tool/services/task/service.py
is_cancelled
A method that checks if a task has been cancelled.
Parameters:
-
task_id(str | None, default:None) –The ID of the task to check. If None, checks current thread.
Returns:
-
bool–True if the task is cancelled, False otherwise.
Source code in dev_tool/services/task/service.py
get
A method that gets all tasks.
Returns:
-
list[TaskResult]–A list of all tasks sorted by creation time.
Source code in dev_tool/services/task/service.py
get_active
A method that gets all active tasks.
Returns:
-
list[TaskResult]–A list of pending and running tasks.
Source code in dev_tool/services/task/service.py
get_completed
A method that gets all completed tasks.
Returns:
-
list[TaskResult]–A list of completed tasks.
Source code in dev_tool/services/task/service.py
get_failed
A method that gets all failed tasks.
Returns:
-
list[TaskResult]–A list of failed tasks.
Source code in dev_tool/services/task/service.py
get_task
A method that gets a specific task by ID.
Parameters:
-
task_id(str) –The task ID to retrieve.
Returns:
-
TaskResult | None–The task result or None if not found.
Source code in dev_tool/services/task/service.py
get_latest_completed
A method that gets the most recently completed task.
Returns:
-
TaskResult | None–The latest completed task or None if none exist.
Source code in dev_tool/services/task/service.py
clear_completed
A method that clears all completed and failed tasks.
Source code in dev_tool/services/task/service.py
remove
A method that removes a specific task.
Parameters:
-
task(str) –The task ID to remove.
Returns:
-
bool–True if the task was removed, False if not found.
Source code in dev_tool/services/task/service.py
has_pending_completion_notifications
A method that checks if there are recent completion notifications.
Returns:
-
bool–True if there are recent completions, False otherwise.
Source code in dev_tool/services/task/service.py
wait
A method that waits for a task to complete.