|
8 | 8 | ResultIsReadyError, |
9 | 9 | TaskiqResultTimeoutError, |
10 | 10 | ) |
11 | | -from taskiq.utils import run_sync |
12 | 11 |
|
13 | 12 | if TYPE_CHECKING: # pragma: no cover |
14 | 13 | from taskiq.abc.result_backend import AsyncResultBackend |
@@ -67,60 +66,6 @@ def wait_result( # noqa: WPS234 |
67 | 66 | """ |
68 | 67 |
|
69 | 68 |
|
70 | | -class SyncTaskiqTask(_Task[_ReturnType]): |
71 | | - """Sync wrapper over AsyncTaskiqTask.""" |
72 | | - |
73 | | - def __init__(self, async_task: "AsyncTaskiqTask[_ReturnType]") -> None: |
74 | | - self.async_task = async_task |
75 | | - |
76 | | - def is_ready(self) -> bool: |
77 | | - """ |
78 | | - Checks if task is completed. |
79 | | -
|
80 | | - :return: True if task is completed. |
81 | | - """ |
82 | | - return run_sync(self.async_task.is_ready()) |
83 | | - |
84 | | - def get_result(self, with_logs: bool = False) -> "TaskiqResult[_ReturnType]": |
85 | | - """ |
86 | | - Get result of a task from result backend. |
87 | | -
|
88 | | - :param with_logs: whether you want to fetch logs from worker. |
89 | | -
|
90 | | - :return: task's return value. |
91 | | - """ |
92 | | - return run_sync(self.async_task.get_result(with_logs=with_logs)) |
93 | | - |
94 | | - def wait_result( |
95 | | - self, |
96 | | - check_interval: float = 0.2, |
97 | | - timeout: float = -1, |
98 | | - with_logs: bool = False, |
99 | | - ) -> "TaskiqResult[_ReturnType]": |
100 | | - """ |
101 | | - Waits until result is ready. |
102 | | -
|
103 | | - This method just checks whether the task is |
104 | | - ready. And if it is it returns the result. |
105 | | -
|
106 | | - It may throw TaskiqResultTimeoutError if |
107 | | - task didn't became ready in provided |
108 | | - period of time. |
109 | | -
|
110 | | - :param check_interval: How often checks are performed. |
111 | | - :param timeout: timeout for the result. |
112 | | - :param with_logs: whether you want to fetch logs from worker. |
113 | | - :return: task's return value. |
114 | | - """ |
115 | | - return run_sync( |
116 | | - self.async_task.wait_result( |
117 | | - check_interval=check_interval, |
118 | | - timeout=timeout, |
119 | | - with_logs=with_logs, |
120 | | - ), |
121 | | - ) |
122 | | - |
123 | | - |
124 | 69 | class AsyncTaskiqTask(_Task[_ReturnType]): |
125 | 70 | """AsyncTask for AsyncResultBackend.""" |
126 | 71 |
|
|
0 commit comments