Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/unit/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions warehouse/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down