Skip to content

Support for @method_decorator in Python 3.5 and later #87

Description

@benwhalley

At present using this inside a class based view:

@method_decorator(cacheback(lifetime=60))
def get_context_data(...):
    ...

Causes an error: AttributeError: 'functools.partial' object has no attribute '__module__'

The error arises in jobs.prepare_args which uses ("%s:%s" % (fn.__module__, fn.__name__),) + args to serialise the function for the queue. The suggestion here: https://stackoverflow.com/questions/20594193/dynamically-created-method-and-decorator-got-error-functools-partial-object-h

Is that in python 3.5 and later a reference to the original function is maintained in the partial. You can access it as .func.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions