From c0cda978642ac433dec00483471059f7ba6816af Mon Sep 17 00:00:00 2001 From: Martijn Jacobs Date: Wed, 17 Apr 2019 14:49:15 +0200 Subject: [PATCH] Don't save the next_run field as TZ aware when USE_TZ is False arrow always returns a tz aware datetime, and we don't want this when we explicitly configured django with USE_TZ=False. This causes issues with MySQL. --- 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 23a9761..3babfd8 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -16,6 +16,7 @@ import socket import traceback # Django from django import db +from django.conf import settings from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from multiprocessing import Event, Process, Value, current_process @@ -529,7 +530,9 @@ def scheduler(broker=None): next_run = next_run.replace(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