Procházet zdrojové kódy

[Django] Ignore InterfaceError also after fork (Issue #2996)

Ask Solem před 9 roky
rodič
revize
baa1282c04
1 změnil soubory, kde provedl 8 přidání a 2 odebrání
  1. 8 2
      celery/fixups/django.py

+ 8 - 2
celery/fixups/django.py

@@ -232,15 +232,21 @@ class DjangoWorkerFixup(object):
         try:
             for c in self._db.connections.all():
                 if c and c.connection:
-                    _maybe_close_fd(c.connection)
+                    self._maybe_close_db_fd(c.connection)
         except AttributeError:
             if self._db.connection and self._db.connection.connection:
-                _maybe_close_fd(self._db.connection.connection)
+                self._maybe_close_db_fd(self._db.connection.connection)
 
         # use the _ version to avoid DB_REUSE preventing the conn.close() call
         self._close_database()
         self.close_cache()
 
+    def _maybe_close_db_fd(self, fd):
+        try:
+            _maybe_close_fd(fd)
+        except self.interface_errors:
+            pass
+
     def on_task_prerun(self, sender, **kwargs):
         """Called before every task."""
         if not getattr(sender.request, 'is_eager', False):