From aba033ae63264d3f9432d23282ba10912dbee1e7 Mon Sep 17 00:00:00 2001 From: cp2004 <31997505+cp2004@users.noreply.github.com> Date: Tue, 6 Oct 2020 15:40:15 +0100 Subject: [PATCH] :bug: Make octoprint.util.ResettableTimer daemon thread by default See also: * https://github.com/j7126/OctoPrint-Dashboard/pull/219 * https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/pull/200 Affects plugins that use multiprocessing, since it blocks the shutdown (and release of server address binding), breaking the server. Shouldn't be a breaking change, since it should be run daemon=True anyway to avoid the shutdown problems. --- src/octoprint/util/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index fde527046..a2c921f31 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -1456,7 +1456,7 @@ class ResettableTimer(threading.Thread): on_reset (callable): Callback to call when the timer is reset. """ - def __init__(self, interval, function, args=None, kwargs=None, on_reset=None, on_cancelled=None): + def __init__(self, interval, function, args=None, kwargs=None, on_reset=None, on_cancelled=None, daemon=True): threading.Thread.__init__(self) self._event = threading.Event() self._mutex = threading.Lock() @@ -1473,6 +1473,7 @@ class ResettableTimer(threading.Thread): self.kwargs = kwargs self.on_cancelled = on_cancelled self.on_reset = on_reset + self.daemon = daemon def run(self):