From 25d1e3e3a0c21fdbabae6e38c79b4be2325ff3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=9C=88=E5=9C=88?= Date: Wed, 15 Apr 2020 20:57:27 +0800 Subject: [PATCH] Fix issue when using USE_TZ=False with MySQL #353 --- django_q/cluster.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django_q/cluster.py b/django_q/cluster.py index c6bffae..d84af46 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -20,6 +20,7 @@ import arrow # Django from django import db +from django.conf import settings from django.utils import timezone from django.utils.translation import gettext_lazy as _ @@ -589,7 +590,9 @@ def scheduler(broker=None): next_run = next_run.shift(years=+1) if Conf.CATCH_UP or next_run > arrow.utcnow(): break - s.next_run = next_run.datetime + # arrow always returns a tz aware datetime, and we don't want + # this when we explicitly configured django with USE_TZ=False + s.next_run = next_run.datetime if settings.USE_TZ else next_run.datetime.replace(tzinfo=None) s.repeats += -1 # send it to the cluster q_options["broker"] = broker