aboutsummaryrefslogtreecommitdiffstats
path: root/servo/management
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2021-06-06 14:33:41 +0300
committerFilipp Lepalaan <filipp@mac.com>2021-06-06 14:33:41 +0300
commitbc273f17cd8e08c6944660b8633ba41763f292b2 (patch)
tree64417ccdb1578292979577dde4245100d9d07f36 /servo/management
parent86316988dce1558e619a07c164f3e545f64d9e57 (diff)
downloadServo-bc273f17cd8e08c6944660b8633ba41763f292b2.tar.gz
Servo-bc273f17cd8e08c6944660b8633ba41763f292b2.tar.bz2
Servo-bc273f17cd8e08c6944660b8633ba41763f292b2.zip
Migrate Celery to RQ
Diffstat (limited to 'servo/management')
-rw-r--r--servo/management/commands/scheduler.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/servo/management/commands/scheduler.py b/servo/management/commands/scheduler.py
new file mode 100644
index 0000000..18018e5
--- /dev/null
+++ b/servo/management/commands/scheduler.py
@@ -0,0 +1,28 @@
+from datetime import datetime
+
+import django_rq
+from django.core.management.base import BaseCommand
+from django_rq.management.commands import rqscheduler
+
+
+from servo.tasks import check_mail
+
+
+scheduler = django_rq.get_scheduler('default')
+
+
+class Command(rqscheduler.Command):
+
+ help = "Start task scheduler"
+
+ def handle(self, *args, **kwargs):
+ for job in scheduler.get_jobs():
+ job.delete()
+
+ scheduler.schedule(
+ scheduled_time=datetime.utcnow(), # Time for first execution, in UTC timezone
+ func=check_mail, # Function to be queued
+ interval=300, # Time before the function is called again, in seconds
+ )
+
+ super(Command, self).handle(*args, **kwargs)