Explorar el Código

Thread pool can't use threading.local since it's broken. Closes #863

Ask Solem hace 12 años
padre
commit
3d4b7cc22b
Se han modificado 2 ficheros con 8 adiciones y 1 borrados
  1. 6 0
      celery/concurrency/threads.py
  2. 2 1
      celery/utils/threads.py

+ 6 - 0
celery/concurrency/threads.py

@@ -8,10 +8,16 @@
 """
 from __future__ import absolute_import
 
+import os
+
 from celery.utils.compat import UserDict
 
 from .base import apply_target, BasePool
 
+#: Makes sure we don't use threading.local for stacks
+#: since apparently they don't work properly.
+os.environ['USE_PURE_LOCALS'] = '1'
+
 
 class NullDict(UserDict):
 

+ 2 - 1
celery/utils/threads.py

@@ -20,6 +20,7 @@ _Event = threading._Event
 
 active_count = (getattr(threading, 'active_count', None) or
                 threading.activeCount)
+USE_PURE_LOCALS = os.environ.get("USE_PURE_LOCALS")
 
 
 class Event(_Event):
@@ -92,7 +93,7 @@ class bgThread(Thread):
         if self.is_alive():
             self.join(1e100)
 
-if detect_environment() == 'default':
+if detect_environment() == 'default' and not USE_PURE_LOCALS:
     class LocalStack(threading.local):
 
         def __init__(self):