Trying to use the auto retry on exception feature of celery tasks. I've tried to get it to work every way listed in the celery docs and it always fails.
Docs link
Here is the trace from the worker, Sorry I don't have a better way to parse this out from the docker logs.
celeryworker | [2023-04-05 13:17:05,970: INFO/SpawnProcess-148] Task task_retrytest[6a08dbdc-76b2-42d9-8b6f-847183ff0936] received
celeryworker | [2023-04-05 13:17:05,988: WARNING/ForkPoolWorker-6] --- Logging error ---
celeryworker | [2023-04-05 13:17:05,990: WARNING/ForkPoolWorker-6] Traceback (most recent call last):
celeryworker | [2023-04-05 13:17:05,991: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery_aio_pool/tracer.py", line 237, in trace_task
celeryworker | R = retval = AsyncIOPool.run_in_pool(fun, *args, **kwargs)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:05,991: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery_aio_pool/pool.py", line 222, in run_in_pool
celeryworker | return worker_pool.run(
celeryworker | ^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:05,991: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery_aio_pool/pool.py", line 203, in run
celeryworker | raise error
celeryworker | [2023-04-05 13:17:05,991: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/asyncio/threads.py", line 25, in to_thread
celeryworker | return await loop.run_in_executor(None, func_call)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:05,992: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
celeryworker | result = self.fn(*self.args, **self.kwargs)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:05,992: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/app/task.py", line 392, in __call__
celeryworker | return self.run(*args, **kwargs)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:05,993: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/app/autoretry.py", line 54, in run
celeryworker | ret = task.retry(exc=exc, **retry_kwargs)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:05,993: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/app/task.py", line 701, in retry
celeryworker | raise_with_context(exc or Retry('Task can be retried', None))
celeryworker | [2023-04-05 13:17:05,993: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/app/autoretry.py", line 34, in run
celeryworker | return task._orig_run(*args, **kwargs)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:05,993: WARNING/ForkPoolWorker-6] File "/app/hawkeye/tasks/amazon/ad/report/advertisedproduct.py", line 60, in task_retrytest
celeryworker | raise ADAPIRetriableException("test")
celeryworker | [2023-04-05 13:17:05,994: WARNING/ForkPoolWorker-6] adapi_pydantic.base.exceptions.ADAPIRetriableException: test
celeryworker | [2023-04-05 13:17:05,996: WARNING/ForkPoolWorker-6]
celeryworker | During handling of the above exception, another exception occurred:
celeryworker | [2023-04-05 13:17:05,996: WARNING/ForkPoolWorker-6] Traceback (most recent call last):
celeryworker | [2023-04-05 13:17:05,999: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/logging/__init__.py", line 1110, in emit
celeryworker | msg = self.format(record)
celeryworker | ^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:05,999: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/logging/__init__.py", line 953, in format
celeryworker | return fmt.format(record)
celeryworker | ^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:06,000: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/utils/log.py", line 146, in format
celeryworker | msg = super().format(record)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:06,000: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/logging/__init__.py", line 695, in format
celeryworker | record.exc_text = self.formatException(record.exc_info)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:06,001: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/utils/log.py", line 142, in formatException
celeryworker | r = super().formatException(ei)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:06,001: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/logging/__init__.py", line 645, in formatException
celeryworker | traceback.print_exception(ei[0], ei[1], tb, None, sio)
celeryworker | [2023-04-05 13:17:06,001: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/traceback.py", line 124, in print_exception
celeryworker | te = TracebackException(type(value), value, tb, limit=limit, compact=True)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:06,001: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/traceback.py", line 690, in __init__
celeryworker | self.stack = StackSummary._extract_from_extended_frame_gen(
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:06,001: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/traceback.py", line 416, in _extract_from_extended_frame_gen
celeryworker | for f, (lineno, end_lineno, colno, end_colno) in frame_gen:
celeryworker | [2023-04-05 13:17:06,002: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/traceback.py", line 353, in _walk_tb_with_full_positions
celeryworker | positions = _get_code_position(tb.tb_frame.f_code, tb.tb_lasti)
celeryworker | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:06,002: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/traceback.py", line 366, in _get_code_position
celeryworker | positions_gen = code.co_positions()
celeryworker | ^^^^^^^^^^^^^^^^^
celeryworker | [2023-04-05 13:17:06,002: WARNING/ForkPoolWorker-6] AttributeError: '_Code' object has no attribute 'co_positions'
celeryworker | [2023-04-05 13:17:06,002: WARNING/ForkPoolWorker-6] Call stack:
celeryworker | [2023-04-05 13:17:06,009: WARNING/ForkPoolWorker-6] File "<string>", line 1, in <module>
celeryworker | [2023-04-05 13:17:06,010: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/multiprocessing/spawn.py", line 120, in spawn_main
celeryworker | exitcode = _main(fd, parent_sentinel)
celeryworker | [2023-04-05 13:17:06,010: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/multiprocessing/spawn.py", line 133, in _main
celeryworker | return self._bootstrap(parent_sentinel)
celeryworker | [2023-04-05 13:17:06,010: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
celeryworker | self.run()
celeryworker | [2023-04-05 13:17:06,010: WARNING/ForkPoolWorker-6] File "/usr/local/lib/python3.11/multiprocessing/process.py", line 108, in run
celeryworker | self._target(*self._args, **self._kwargs)
celeryworker | [2023-04-05 13:17:06,010: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/watchgod/cli.py", line 51, in run_function
celeryworker | func()
celeryworker | [2023-04-05 13:17:06,010: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/__main__.py", line 15, in main
celeryworker | sys.exit(_main())
celeryworker | [2023-04-05 13:17:06,010: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/bin/celery.py", line 217, in main
celeryworker | return celery(auto_envvar_prefix="CELERY")
celeryworker | [2023-04-05 13:17:06,010: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
celeryworker | return self.main(*args, **kwargs)
celeryworker | [2023-04-05 13:17:06,010: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/click/core.py", line 1055, in main
celeryworker | rv = self.invoke(ctx)
celeryworker | [2023-04-05 13:17:06,011: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
celeryworker | return _process_result(sub_ctx.command.invoke(sub_ctx))
celeryworker | [2023-04-05 13:17:06,011: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
celeryworker | return ctx.invoke(self.callback, **ctx.params)
celeryworker | [2023-04-05 13:17:06,011: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/click/core.py", line 760, in invoke
celeryworker | return __callback(*args, **kwargs)
celeryworker | [2023-04-05 13:17:06,011: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
celeryworker | return f(get_current_context(), *args, **kwargs)
celeryworker | [2023-04-05 13:17:06,011: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/bin/base.py", line 134, in caller
celeryworker | return f(ctx, *args, **kwargs)
celeryworker | [2023-04-05 13:17:06,011: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/bin/worker.py", line 351, in worker
celeryworker | worker.start()
celeryworker | [2023-04-05 13:17:06,011: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/worker/worker.py", line 203, in start
celeryworker | self.blueprint.start(self)
celeryworker | [2023-04-05 13:17:06,012: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/bootsteps.py", line 116, in start
celeryworker | step.start(parent)
celeryworker | [2023-04-05 13:17:06,012: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/bootsteps.py", line 365, in start
celeryworker | return self.obj.start()
celeryworker | [2023-04-05 13:17:06,012: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/concurrency/base.py", line 129, in start
celeryworker | self.on_start()
celeryworker | [2023-04-05 13:17:06,012: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/concurrency/prefork.py", line 109, in on_start
celeryworker | P = self._pool = Pool(processes=self.limit,
celeryworker | [2023-04-05 13:17:06,012: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/concurrency/asynpool.py", line 463, in __init__
celeryworker | super().__init__(processes, *args, **kwargs)
celeryworker | [2023-04-05 13:17:06,012: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/pool.py", line 1046, in __init__
celeryworker | self._create_worker_process(i)
celeryworker | [2023-04-05 13:17:06,012: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/concurrency/asynpool.py", line 480, in _create_worker_process
celeryworker | return super()._create_worker_process(i)
celeryworker | [2023-04-05 13:17:06,012: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/pool.py", line 1158, in _create_worker_process
celeryworker | w.start()
celeryworker | [2023-04-05 13:17:06,013: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/process.py", line 124, in start
celeryworker | self._popen = self._Popen(self)
celeryworker | [2023-04-05 13:17:06,013: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/context.py", line 333, in _Popen
celeryworker | return Popen(process_obj)
celeryworker | [2023-04-05 13:17:06,013: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/popen_fork.py", line 24, in __init__
celeryworker | self._launch(process_obj)
celeryworker | [2023-04-05 13:17:06,013: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/popen_fork.py", line 79, in _launch
celeryworker | code = process_obj._bootstrap()
celeryworker | [2023-04-05 13:17:06,013: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/process.py", line 327, in _bootstrap
celeryworker | self.run()
celeryworker | [2023-04-05 13:17:06,013: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/process.py", line 114, in run
celeryworker | self._target(*self._args, **self._kwargs)
celeryworker | [2023-04-05 13:17:06,013: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/pool.py", line 292, in __call__
celeryworker | sys.exit(self.workloop(pid=pid))
celeryworker | [2023-04-05 13:17:06,014: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/billiard/pool.py", line 362, in workloop
celeryworker | result = (True, prepare_result(fun(*args, **kwargs)))
celeryworker | [2023-04-05 13:17:06,014: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/app/trace.py", line 649, in fast_trace_task
celeryworker | R, I, T, Rstr = tasks[task].__trace__(
celeryworker | [2023-04-05 13:17:06,014: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery_aio_pool/tracer.py", line 254, in trace_task
celeryworker | I, R, state, retval = on_error(task_request, exc)
celeryworker | [2023-04-05 13:17:06,014: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery_aio_pool/tracer.py", line 154, in on_error
celeryworker | R = I.handle_error_state(
celeryworker | [2023-04-05 13:17:06,014: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/app/trace.py", line 178, in handle_error_state
celeryworker | return {
celeryworker | [2023-04-05 13:17:06,014: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/app/trace.py", line 237, in handle_failure
celeryworker | self._log_error(task, req, einfo)
celeryworker | [2023-04-05 13:17:06,014: WARNING/ForkPoolWorker-6] File "/opt/pysetup/.venv/lib/python3.11/site-packages/celery/app/trace.py", line 265, in _log_error
celeryworker | logger.log(policy.severity, policy.format.strip(), context,