Browse Source

celery.utils.threads: Ignore TypeError at interpreter shutdown

Ask Solem 13 năm trước cách đây
mục cha
commit
b78b84a90e
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  1. 6 0
      celery/utils/threads.py

+ 6 - 0
celery/utils/threads.py

@@ -49,6 +49,12 @@ class bgThread(Thread):
                 self.on_crash("%r crashed: %r", self.name, exc, exc_info=True)
                 # exiting by normal means does not work here, so force exit.
                 os._exit(1)
+        try:
+            self._is_stopped.set()
+        except TypeError:  # pragma: no cover
+            # we lost the race at interpreter shutdown,
+            # so gc collected built-in modules.
+            pass
         self._is_stopped.set()
 
     def stop(self):