Skip to content

Commit

Permalink
Merge pull request #50 from syleam/11.0-fix-queue-property-compatibility
Browse files Browse the repository at this point in the history
[FIX] Get attributes on the class instead of recordsets
  • Loading branch information
guewen committed Feb 8, 2018
2 parents ba5522f + 4ebb245 commit 221dd95
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions queue_job/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@ class Base(models.AbstractModel):
def _register_hook(self):
""" register marked jobs """
super(Base, self)._register_hook()
job_methods = set()
for attr_name in dir(self):
# _cache on models is a lazy_property which raises an
# AssertionError when called on a empty model, just skip it.
if attr_name == '_cache':
continue
try:
attr = getattr(self, attr_name)
except AttributeError:
continue
if inspect.ismethod(attr) and getattr(attr, 'delayable', None):
job_methods.add(attr)
job_methods = [
method for __, method
in inspect.getmembers(self.__class__, predicate=inspect.ismethod)
if getattr(method, 'delayable', None)
]
for job_method in job_methods:
self.env['queue.job.function']._register_job(job_method)

Expand Down

0 comments on commit 221dd95

Please sign in to comment.