I'm running pytest-celery and want to execute a saved task group, like in the following examples.
Creating a task group, then running it works:
@pytest.mark.django_db(transaction=True) # https://stackoverflow.com/questions/31504591/interfaceerror-connection-already-closed-using-django-celery-scrapy
@pytest.mark.celery(task_always_eager=True) # https://github.com/celery/celery/issues/3642
def test_celery_group(
celery_app,
celery_worker,
):
@celery_app.task
def mul(x, y):
return x * y
celery_worker.reload() # force task registration https://github.com/celery/celery/issues/3642
g = group([mul.s(3, 3), mul.s(4, 4)])()
assert g.get(timeout=10) == [9, 16]
But if I try to save the group and then restore it:
@pytest.mark.django_db(transaction=True) # https://stackoverflow.com/questions/31504591/interfaceerror-connection-already-closed-using-django-celery-scrapy
@pytest.mark.celery(task_always_eager=True) # https://github.com/celery/celery/issues/3642
def test_celery_group_restore(
celery_app,
celery_worker,
):
@celery_app.task
def mul(x, y):
return x * y
celery_worker.reload() # force task registration https://github.com/celery/celery/issues/3642
g = group([mul.s(3, 3), mul.s(4, 4)])()
g.save()
restored_group_result = result.GroupResult.restore(g.id)
assert restored_group_result.get(timeout=10) == [9, 16]
celery.exceptions.TimeoutError: The operation timed out.
is raised with no other information. The timeout duration of 10 seconds is more than enough (I also tried 100 seconds).
pip freeze
displays the following versions:
pytest==7.2.1
pytest-celery==0.0.0
What am I doing wrong?