MCPcopy Create free account
hub / github.com/celery/celery / _query_task

Method _query_task

celery/backends/database/__init__.py:146–167  ·  view source on GitHub ↗

Query task by id, falling back to deferring missing columns from database.

(self, session, task_id, for_update=False)

Source from the content-addressed store, hash-verified

144 **self.engine_options)
145
146 def _query_task(self, session, task_id, for_update=False):
147 """Query task by id, falling back to deferring missing columns from database."""
148 query = session.query(self.task_cls)
149 if for_update:
150 # Lock the row, and read it again even if the session has it.
151 query = query.with_for_update().populate_existing()
152 try:
153 tasks = list(query.filter(self.task_cls.task_id == task_id))
154 return tasks and tasks[0]
155 except DatabaseError as exc:
156 exc_str = str(exc).lower()
157 defers = []
158 if 'children' in exc_str and hasattr(self.task_cls, 'children'):
159 defers.append(defer(self.task_cls.children))
160 if 'stamps' in exc_str and hasattr(self.task_cls, 'stamps'):
161 defers.append(defer(self.task_cls.stamps))
162 if defers:
163 tasks = list(query.options(*defers).filter(
164 self.task_cls.task_id == task_id
165 ))
166 return tasks and tasks[0]
167 raise
168
169 def _store_result(self, task_id, result, state, traceback=None,
170 request=None, **kwargs):

Calls 2

filterMethod · 0.80
optionsMethod · 0.80