From 57ed764734ff150445ae8c9dd9654a820e821369 Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Wed, 15 Jul 2020 13:10:49 -0500 Subject: [PATCH] Revert "Fix celerybeat cleanup error (#8269)" This reverts commit 720444abe513b88190271c9f7567fb0324704981. --- tests/unit/test_tasks.py | 11 +++++++++++ warehouse/tasks.py | 2 ++ 2 files changed, 13 insertions(+) diff --git a/tests/unit/test_tasks.py b/tests/unit/test_tasks.py index 8824382da2af..cbe28996d8ff 100644 --- a/tests/unit/test_tasks.py +++ b/tests/unit/test_tasks.py @@ -38,6 +38,17 @@ def test_tls_redis_backend(): class TestWarehouseTask: + def test_header(self): + def header(request, thing): + pass + + task_type = type( + "Foo", (tasks.WarehouseTask,), {"__header__": staticmethod(header)} + ) + + obj = task_type() + obj.__header__(object()) + def test_call(self, monkeypatch): request = pretend.stub() registry = pretend.stub() diff --git a/warehouse/tasks.py b/warehouse/tasks.py index 99c3e7d542c4..9c581e9aa7ab 100644 --- a/warehouse/tasks.py +++ b/warehouse/tasks.py @@ -51,6 +51,8 @@ def _params_from_url(self, url, defaults): class WarehouseTask(celery.Task): def __new__(cls, *args, **kwargs): obj = super().__new__(cls, *args, **kwargs) + if getattr(obj, "__header__", None) is not None: + obj.__header__ = functools.partial(obj.__header__, object()) # We do this here instead of inside of __call__ so that exceptions # coming from the transaction manager get caught by the autoretry