MCPcopy Create free account
hub / github.com/closeio/tasktiger / Task

Class Task

tasktiger/task.py:43–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42
43class Task:
44 def __init__(
45 self,
46 tiger: "TaskTiger",
47 func: Optional[Callable] = None,
48 args: Optional[Any] = None,
49 kwargs: Optional[Any] = None,
50 queue: Optional[str] = None,
51 hard_timeout: Optional[float] = None,
52 unique: Optional[bool] = None,
53 unique_key: Optional[Collection[str]] = None,
54 lock: Optional[bool] = None,
55 lock_key: Optional[Collection[str]] = None,
56 retry: Optional[bool] = None,
57 retry_on: Optional[Collection[Type[BaseException]]] = None,
58 retry_method: Optional[
59 Union[Callable[[int], float], Tuple[Callable[..., float], Tuple]]
60 ] = None,
61 max_queue_size: Optional[int] = None,
62 max_stored_executions: Optional[int] = None,
63 runner_class: Optional[Type["BaseRunner"]] = None,
64 # internal variables
65 _data: Any = None,
66 _state: Any = None,
67 _ts: Any = None,
68 _executions: Optional[List[Dict[str, Any]]] = None,
69 ):
70 """
71 Queues a task. See README.rst for an explanation of the options.
72 """
73
74 if func and queue is None:
75 queue = Task.queue_from_function(func, tiger)
76
77 self.tiger = tiger
78 self._func = func
79 self._queue = queue
80 self._state = _state
81 self._ts = _ts
82 self._executions = _executions or []
83
84 # Internal initialization based on raw data.
85 if _data is not None:
86 self._data = _data
87 return
88
89 assert func
90
91 serialized_name = serialize_func_name(func)
92
93 if unique is None:
94 unique = getattr(func, "_task_unique", False)
95
96 if unique_key is None:
97 unique_key = getattr(func, "_task_unique_key", None)
98
99 if lock is None:
100 lock = getattr(func, "_task_lock", False)

Callers 15

test_delayMethod · 0.90
test_delay_scheduledMethod · 0.90
test_executeMethod · 0.90
test_tasks_from_queueMethod · 0.90
test_eagerMethod · 0.90
test_current_taskMethod · 0.90
test_current_tasksMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_delayMethod · 0.72
test_delay_scheduledMethod · 0.72
test_executeMethod · 0.72
test_tasks_from_queueMethod · 0.72
test_eagerMethod · 0.72
test_current_taskMethod · 0.72
test_current_tasksMethod · 0.72