diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2012-10-07 21:48:07 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2012-10-07 21:48:07 -0400 |
| commit | e1f2cfbe0feeb1ea9e239f2fca6e4fb1d0bfbb14 (patch) | |
| tree | aa46e9ce08ee93acbb1f3a3139a71873741b70cc | |
| parent | 3bfc83c63ccea6687a53542758f0487f23ae7529 (diff) | |
| download | cherrypy-git-e1f2cfbe0feeb1ea9e239f2fca6e4fb1d0bfbb14.tar.gz | |
Timer class was renamed from _Timer to Timer in Python 3.3. This change adds a compatibility shim to detect this change and reference the base class accordingly. Fixes #1163.
--HG--
branch : cherrypy-3.2.x
| -rw-r--r-- | cherrypy/_cpcompat.py | 7 | ||||
| -rw-r--r-- | cherrypy/process/plugins.py | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/cherrypy/_cpcompat.py b/cherrypy/_cpcompat.py index ec2a47af..eb6a712a 100644 --- a/cherrypy/_cpcompat.py +++ b/cherrypy/_cpcompat.py @@ -18,6 +18,7 @@ output. import os import re import sys +import threading if sys.version_info >= (3, 0): py3k = True @@ -325,3 +326,9 @@ except NameError: # Python 2 def next(i): return i.next() + +if sys.version_info >= (3,3): + Timer = threading.Timer +else: + # Python 3.2 and earlier + Timer = threading._Timer diff --git a/cherrypy/process/plugins.py b/cherrypy/process/plugins.py index 57b665b3..32a0c7e0 100644 --- a/cherrypy/process/plugins.py +++ b/cherrypy/process/plugins.py @@ -7,7 +7,7 @@ import sys import time import threading -from cherrypy._cpcompat import basestring, get_daemon, get_thread_ident, ntob, set +from cherrypy._cpcompat import basestring, get_daemon, get_thread_ident, ntob, set, Timer # _module__file__base is used by Autoreload to make # absolute any filenames retrieved from sys.modules which are not @@ -421,7 +421,7 @@ class PIDFile(SimplePlugin): pass -class PerpetualTimer(threading._Timer): +class PerpetualTimer(Timer): """A responsive subclass of threading._Timer whose run() method repeats. Use this timer only when you really need a very interruptible timer; |
