MCPcopy
hub / github.com/celery/celery / is_aborted

Method is_aborted

celery/contrib/abortable.py:147–165  ·  view source on GitHub ↗

Return true if task is aborted. Checks against the backend whether this :class:`AbortableAsyncResult` is :const:`ABORTED`. Always return :const:`False` in case the `task_id` parameter refers to a regular (non-abortable) :class:`Task`. Be aware that invoking

(self, **kwargs)

Source from the content-addressed store, hash-verified

145 return AbortableAsyncResult(task_id, backend=self.backend)
146
147 def is_aborted(self, **kwargs):
148 """Return true if task is aborted.
149
150 Checks against the backend whether this
151 :class:`AbortableAsyncResult` is :const:`ABORTED`.
152
153 Always return :const:`False` in case the `task_id` parameter
154 refers to a regular (non-abortable) :class:`Task`.
155
156 Be aware that invoking this method will cause a hit in the
157 backend (for example a database query), so find a good balance
158 between calling it regularly (for responsiveness), but not too
159 often (for performance).
160 """
161 task_id = kwargs.get('task_id', self.request.id)
162 result = self.AsyncResult(task_id)
163 if not isinstance(result, AbortableAsyncResult):
164 return False
165 return result.is_aborted()

Callers 3

test_is_not_abortedMethod · 0.45

Calls 2

AsyncResultMethod · 0.95
getMethod · 0.45

Tested by 3

test_is_not_abortedMethod · 0.36