Skip to content

Commit

Permalink
[fix] fix error on task initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Lyisenkov committed Sep 25, 2018
1 parent 1613f17 commit e78d503
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions static_sitemaps/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
if conf.CELERY_TASK_REPETITION or conf.CELERY_TASK_SCHEDULE:
class GenerateSitemap(PeriodicTask):

def __init__(self):
def __new__(cls, *args, **kwargs):
if conf.CELERY_TASK_REPETITION and conf.CELERY_TASK_SCHEDULE:
raise ValueError(
'You should set one setting of STATICSITEMAPS_REFRESH_AFTER or STATICSITEMAPS_REFRESH_ON')
if conf.CELERY_TASK_SCHEDULE:
self.run_every = conf.CELERY_TASK_SCHEDULE
cls.run_every = conf.CELERY_TASK_SCHEDULE
else:
self.run_every = timedelta(minutes=(conf.CELERY_TASK_REPETITION or 60))
super().__init__()
cls.run_every = timedelta(minutes=(conf.CELERY_TASK_REPETITION or 60))

def run(self, **kwargs):
generate_sitemap(verbosity=1)

0 comments on commit e78d503

Please sign in to comment.