瀏覽代碼

Removes Py2.6 workaround for missing WeakSet

Ask Solem 11 年之前
父節點
當前提交
e80c545f6a
共有 1 個文件被更改,包括 1 次插入26 次删除
  1. 1 26
      celery/_state.py

+ 1 - 26
celery/_state.py

@@ -19,31 +19,6 @@ import weakref
 from celery.local import Proxy
 from celery.local import Proxy
 from celery.utils.threads import LocalStack
 from celery.utils.threads import LocalStack
 
 
-try:
-    from weakref import WeakSet as AppSet
-except ImportError:  # XXX Py2.6
-
-    class AppSet(object):  # noqa
-
-        def __init__(self):
-            self._refs = set()
-
-        def add(self, app):
-            self._refs.add(weakref.ref(app))
-
-        def __iter__(self):
-            dirty = []
-            try:
-                for appref in self._refs:
-                    app = appref()
-                    if app is None:
-                        dirty.append(appref)
-                    else:
-                        yield app
-            finally:
-                while dirty:
-                    self._refs.discard(dirty.pop())
-
 __all__ = ['set_default_app', 'get_current_app', 'get_current_task',
 __all__ = ['set_default_app', 'get_current_app', 'get_current_task',
            'get_current_worker_task', 'current_app', 'current_task']
            'get_current_worker_task', 'current_app', 'current_task']
 
 
@@ -51,7 +26,7 @@ __all__ = ['set_default_app', 'get_current_app', 'get_current_task',
 default_app = None
 default_app = None
 
 
 #: List of all app instances (weakrefs), must not be used directly.
 #: List of all app instances (weakrefs), must not be used directly.
-_apps = AppSet()
+_apps = weakref.WeakSet()
 
 
 _task_join_will_block = False
 _task_join_will_block = False