summaryrefslogtreecommitdiff
path: root/cherrypy/process/plugins.py
diff options
context:
space:
mode:
authorRene Peinthor <peinthor@gmail.com>2012-12-11 12:53:48 +0100
committerRene Peinthor <peinthor@gmail.com>2012-12-11 12:53:48 +0100
commit9e4be1a8c48feb0cdca5a67007cb6a69c2a597f8 (patch)
treef88aeb31374846cc0fb9e099651279c36fb15abf /cherrypy/process/plugins.py
parentd7e58da0f20b197fea885eb23c851b773b7aee87 (diff)
downloadcherrypy-git-9e4be1a8c48feb0cdca5a67007cb6a69c2a597f8.tar.gz
Python3.3 doesn't use setdaemon for initializing the daemon var anymore
So BackgroundTask would always use the current threads daemon mode on py3.3
Diffstat (limited to 'cherrypy/process/plugins.py')
-rw-r--r--cherrypy/process/plugins.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/cherrypy/process/plugins.py b/cherrypy/process/plugins.py
index 80473ff3..4437e36a 100644
--- a/cherrypy/process/plugins.py
+++ b/cherrypy/process/plugins.py
@@ -460,7 +460,7 @@ class BackgroundTask(threading.Thread):
it won't delay stopping the whole process.
"""
- def __init__(self, interval, function, args=[], kwargs={}, bus=None):
+ def __init__(self, interval, function, args=[], kwargs={}, bus=None, *, daemon=True):
threading.Thread.__init__(self)
self.interval = interval
self.function = function
@@ -468,6 +468,10 @@ class BackgroundTask(threading.Thread):
self.kwargs = kwargs
self.running = False
self.bus = bus
+ if daemon is not None:
+ self.daemon = daemon
+ else:
+ self.daemon = current_thread().daemon
def cancel(self):
self.running = False
@@ -487,9 +491,6 @@ class BackgroundTask(threading.Thread):
# Quit on first error to avoid massive logs.
raise
- def _set_daemon(self):
- return True
-
class Monitor(SimplePlugin):
"""WSPBus listener to periodically run a callback in its own thread."""