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

Method __init__

tasktiger/task.py:44–168  ·  view source on GitHub ↗

Queues a task. See README.rst for an explanation of the options.

(
        self,
        tiger: "TaskTiger",
        func: Optional[Callable] = None,
        args: Optional[Any] = None,
        kwargs: Optional[Any] = None,
        queue: Optional[str] = None,
        hard_timeout: Optional[float] = None,
        unique: Optional[bool] = None,
        unique_key: Optional[Collection[str]] = None,
        lock: Optional[bool] = None,
        lock_key: Optional[Collection[str]] = None,
        retry: Optional[bool] = None,
        retry_on: Optional[Collection[Type[BaseException]]] = None,
        retry_method: Optional[
            Union[Callable[[int], float], Tuple[Callable[..., float], Tuple]]
        ] = None,
        max_queue_size: Optional[int] = None,
        max_stored_executions: Optional[int] = None,
        runner_class: Optional[Type["BaseRunner"]] = None,
        # internal variables
        _data: Any = None,
        _state: Any = None,
        _ts: Any = None,
        _executions: Optional[List[Dict[str, Any]]] = None,
    )

Source from the content-addressed store, hash-verified

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)
101

Callers

nothing calls this directly

Calls 5

serialize_func_nameFunction · 0.85
gen_unique_idFunction · 0.85
gen_idFunction · 0.85
serialize_retry_methodFunction · 0.85
queue_from_functionMethod · 0.80

Tested by

no test coverage detected