Added sleep for non-posix, allow supported signals
authorMiodrag Milanovic <mmicko@gmail.com>
Wed, 15 Jan 2020 07:09:11 +0000 (08:09 +0100)
committerMiodrag Milanovic <mmicko@gmail.com>
Wed, 15 Jan 2020 07:09:11 +0000 (08:09 +0100)
sbysrc/sby_core.py

index b01dc1edc7cdc627206928c294fb89277bff9927..5d41fd8e9c0e708b22f2b06f4651363f260c2a9c 100644 (file)
 # 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()