Browse Source

Removes Py2.6 workaround for missing WeakSet

Ask Solem 11 years ago
parent
commit
e80c545f6a
1 changed files with 1 additions and 26 deletions
  1. 1 26
      celery/_state.py

+ 1 - 26
celery/_state.py

@@ -19,31 +19,6 @@ import weakref
 from celery.local import Proxy
 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',
            '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
 
 #: List of all app instances (weakrefs), must not be used directly.
-_apps = AppSet()
+_apps = weakref.WeakSet()
 
 _task_join_will_block = False