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

Method execute_using_pool

celery/worker/request.py:348–379  ·  view source on GitHub ↗

Used by the worker to send this task to the pool. Arguments: pool (~celery.concurrency.base.TaskPool): The execution pool used to execute this request. Raises: celery.exceptions.TaskRevokedError: if the task was revoked.

(self, pool: BasePool, **kwargs)

Source from the content-addressed store, hash-verified

346 return self._request_dict['correlation_id']
347
348 def execute_using_pool(self, pool: BasePool, **kwargs):
349 """Used by the worker to send this task to the pool.
350
351 Arguments:
352 pool (~celery.concurrency.base.TaskPool): The execution pool
353 used to execute this request.
354
355 Raises:
356 celery.exceptions.TaskRevokedError: if the task was revoked.
357 """
358 task_id = self.id
359 task = self._task
360 if self.revoked():
361 raise TaskRevokedError(task_id)
362
363 time_limit, soft_time_limit = self.time_limits
364 trace = fast_trace_task if self._app.use_fast_trace_task else trace_task_ret
365 result = pool.apply_async(
366 trace,
367 args=(self._type, task_id, self._request_dict, self._body,
368 self._content_type, self._content_encoding),
369 accept_callback=self.on_accepted,
370 timeout_callback=self.on_timeout,
371 callback=self.on_success,
372 error_callback=self.on_failure,
373 soft_timeout=soft_time_limit or task.soft_time_limit,
374 timeout=time_limit or task.time_limit,
375 correlation_id=task_id,
376 )
377 # cannot create weakref to None
378 self._apply_result = maybe(ref, result)
379 return result
380
381 def execute(self, loglevel=None, logfile=None):
382 """Execute the task in a :func:`~celery.app.trace.trace_task`.

Calls 4

revokedMethod · 0.95
TaskRevokedErrorClass · 0.90
maybeFunction · 0.90
apply_asyncMethod · 0.45