Password promt
This commit is contained in:
@@ -43,6 +43,9 @@ class TaskManager:
|
||||
except RuntimeError:
|
||||
self.loop = asyncio.get_event_loop()
|
||||
self.task_futures: Dict[str, asyncio.Future] = {}
|
||||
|
||||
# Load persisted tasks on startup
|
||||
self.load_persisted_tasks()
|
||||
# [/DEF:TaskManager.__init__:Function]
|
||||
|
||||
# [DEF:TaskManager.create_task:Function]
|
||||
@@ -328,8 +331,49 @@ class TaskManager:
|
||||
if task_id in self.task_futures:
|
||||
self.task_futures[task_id].set_result(True)
|
||||
|
||||
self.persist_awaiting_input_tasks()
|
||||
# Remove from persistence as it's no longer awaiting input
|
||||
self.persistence_service.delete_tasks([task_id])
|
||||
# [/DEF:TaskManager.resume_task_with_password:Function]
|
||||
|
||||
# [DEF:TaskManager.clear_tasks:Function]
|
||||
# @PURPOSE: Clears tasks based on status filter.
|
||||
# @PARAM: status (Optional[TaskStatus]) - Filter by task status.
|
||||
# @RETURN: int - Number of tasks cleared.
|
||||
def clear_tasks(self, status: Optional[TaskStatus] = None) -> int:
|
||||
with belief_scope("TaskManager.clear_tasks"):
|
||||
tasks_to_remove = []
|
||||
for task_id, task in list(self.tasks.items()):
|
||||
# If status is provided, match it.
|
||||
# If status is None, match everything EXCEPT RUNNING (unless they are awaiting input/mapping which are technically running but paused?)
|
||||
# Actually, AWAITING_INPUT and AWAITING_MAPPING are distinct statuses in TaskStatus enum.
|
||||
# RUNNING is active execution.
|
||||
|
||||
should_remove = False
|
||||
if status:
|
||||
if task.status == status:
|
||||
should_remove = True
|
||||
else:
|
||||
# Clear all non-active tasks
|
||||
if task.status not in [TaskStatus.RUNNING]:
|
||||
should_remove = True
|
||||
|
||||
if should_remove:
|
||||
tasks_to_remove.append(task_id)
|
||||
|
||||
for tid in tasks_to_remove:
|
||||
# Cancel future if exists (e.g. for AWAITING_INPUT/MAPPING)
|
||||
if tid in self.task_futures:
|
||||
self.task_futures[tid].cancel()
|
||||
del self.task_futures[tid]
|
||||
|
||||
del self.tasks[tid]
|
||||
|
||||
# Remove from persistence
|
||||
self.persistence_service.delete_tasks(tasks_to_remove)
|
||||
|
||||
logger.info(f"Cleared {len(tasks_to_remove)} tasks.")
|
||||
return len(tasks_to_remove)
|
||||
# [/DEF:TaskManager.clear_tasks:Function]
|
||||
|
||||
# [/DEF:TaskManager:Class]
|
||||
# [/DEF:TaskManagerModule:Module]
|
||||
Reference in New Issue
Block a user