Jason R. Coombs avatar 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.

Comments (0)

Files changed (2)


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


 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.