Jason R. Coombs  committed 76135bf

In Python 3.3, threading._Event was renamed to threading.Event. This change creates a compatibility shim and uses that shim in cherrypy.lib.caching. Fixes #1179.

  • Participants
  • Parent commits 8729a25
  • Branches cherrypy-3.2.x

Comments (0)

Files changed (2)

File cherrypy/

 if sys.version_info >= (3,3):
     Timer = threading.Timer
+    Event = threading.Event
     # Python 3.2 and earlier
     Timer = threading._Timer
+    Event = threading._Event

File cherrypy/lib/

 import cherrypy
 from cherrypy.lib import cptools, httputil
-from cherrypy._cpcompat import copyitems, ntob, set_daemon, sorted
+from cherrypy._cpcompat import copyitems, ntob, set_daemon, sorted, Event
 class Cache(object):
         If timeout is None, no waiting is performed nor sentinels used.
         value = self.get(key)
-        if isinstance(value, threading._Event):
+        if isinstance(value, Event):
             if timeout is None:
                 # Ignore the other thread and recalc it ourselves.
                 if debug:
         """Set the cached value for the given key."""
         existing = self.get(key)
         dict.__setitem__(self, key, value)
-        if isinstance(existing, threading._Event):
+        if isinstance(existing, Event):
             # Set Event.result so other threads waiting on it have
             # immediate access without needing to poll the cache again.
             existing.result = value