From 3fd0c73e657ca056c0a2a644faeb98df85671c01 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 15 Jan 2020 08:09:11 +0100 Subject: [PATCH] Added sleep for non-posix, allow supported signals --- sbysrc/sby_core.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index b01dc1e..5d41fd8 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -16,13 +16,13 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # -import os, re, sys +import os, re, sys, signal if os.name == "posix": - import resource, fcntl, signal + import resource, fcntl import subprocess from shutil import copyfile, rmtree from select import select -from time import time, localtime +from time import time, localtime, sleep all_tasks_running = [] @@ -34,8 +34,8 @@ def force_shutdown(signum, frame): if os.name == "posix": signal.signal(signal.SIGHUP, force_shutdown) - signal.signal(signal.SIGINT, force_shutdown) - signal.signal(signal.SIGTERM, force_shutdown) +signal.signal(signal.SIGINT, force_shutdown) +signal.signal(signal.SIGTERM, force_shutdown) def process_filename(filename): if filename.startswith("~/"): @@ -247,6 +247,8 @@ class SbyJob: select(fds, [], [], 1.0) == ([], [], []) except InterruptedError: pass + else: + sleep(0.1) for task in self.tasks_running: task.poll() -- 2.30.2