From 567aeedde6410c7e6aeb0c2c6f221e1a8938b316 Mon Sep 17 00:00:00 2001 From: Stanislav Kaledin Date: Sat, 14 Apr 2018 23:47:03 +0300 Subject: [PATCH] Fixed https://github.com/jarekwg/django-apscheduler/issues/18 --- django_apscheduler/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/django_apscheduler/models.py b/django_apscheduler/models.py index 5a6b405..96bd2bd 100644 --- a/django_apscheduler/models.py +++ b/django_apscheduler/models.py @@ -31,8 +31,12 @@ def __ping(self): def __reconnect(self): LOGGER.warning("Mysql closed the connection. Perform reconnect...") - connection.connection.close() - connection.connection = None + + if connection.connection: + connection.connection.close() + connection.connection = None + else: + LOGGER.warning("Connection was already closed.") class DjangoJob(models.Model):