mirror of
https://github.com/j93es/oauth-backend.git
synced 2026-06-04 04:51:51 +09:00
65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
from typing import Any
|
|
from copy import deepcopy
|
|
|
|
class FalseTrueVarifingTask:
|
|
"""
|
|
A singleton class representing a task that can be either false or true.
|
|
This class is used to handle tasks that require verification of their truth value.
|
|
"""
|
|
|
|
_instance = None
|
|
|
|
def __new__(cls):
|
|
if cls._instance is None:
|
|
cls._instance = super(FalseTrueVarifingTask, cls).__new__(cls)
|
|
cls._instance._initialized = False
|
|
return cls._instance
|
|
|
|
def __init__(self):
|
|
if self._initialized:
|
|
return
|
|
self._is_verifing = False
|
|
self.task_queue = []
|
|
self._initialized = True
|
|
|
|
def reset(self):
|
|
"""
|
|
Reset the task queue and verification status.
|
|
"""
|
|
self._is_verifing = False
|
|
self.task_queue.clear()
|
|
|
|
# 각 addon의 검증 로직에서 해당 함수를 호출하여, 추후 오탐 검증을 위한 작업을 추가할 수 있습니다.
|
|
# TODO: 모델 지정해두기
|
|
def add_task(self, task_name: str, initial_uri: str, data: Any):
|
|
"""
|
|
Add a task to the task queue.
|
|
:param task: The task to be added.
|
|
"""
|
|
self.task_queue.append(
|
|
{
|
|
"task_name": task_name,
|
|
"initial_uri": initial_uri,
|
|
"data": data
|
|
}
|
|
)
|
|
|
|
def start_verification(self):
|
|
"""
|
|
Start the verification process for the tasks in the queue.
|
|
"""
|
|
self._is_verifing = True
|
|
|
|
def get_task_queue(self):
|
|
"""
|
|
Get a copy of the current task queue.
|
|
:return: A copy of the task queue.
|
|
"""
|
|
return deepcopy(self.task_queue)
|
|
|
|
def is_verifing_false_true(self):
|
|
"""
|
|
Get the current verification status.
|
|
:return: True if verification is in progress, False otherwise.
|
|
"""
|
|
return self._is_verifing
|