From 1aed7c2d0084d4f32dc02ed68df21892987602cb Mon Sep 17 00:00:00 2001 From: Ilan Steemers Date: Tue, 29 Sep 2015 10:47:22 +0200 Subject: [PATCH] #79 close django db connection before fork The sentinel saves a statistic to the cache provider just before forking the workers. If this cache provider is a database backend, the connection stays open and gets forked and it crashes. Solution is to close any db connection before forking. --- django_q/cluster.py | 1 + 1 file changed, 1 insertion(+) diff --git a/django_q/cluster.py b/django_q/cluster.py index f0d8d68..343c5ca 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -188,6 +188,7 @@ class Sentinel(object): def spawn_cluster(self): self.pool = [] Stat(self).save() + db.connection.close() # spawn worker pool for __ in range(self.pool_size): self.spawn_worker()