From 4fcb748f95d8164dedcf294d310dfbd556e11307 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 16 Mar 2014 02:41:53 +0100 Subject: fix sleep regression buf + improve xmonad example to listen for changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/__main__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/__main__.py b/src/__main__.py index b177523..669479a 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -244,17 +244,18 @@ def continuous_run(): except KeyboardInterrupt: signal_SIGTERM(0, None) def sleep(seconds): - try: - with sleep_condition: - signal.setitimer(signal.ITIMER_REAL, seconds) - sleep_condition.wait() - except KeyboardInterrupt: - signal_SIGTERM(0, None) - except: + if not sleep == 0: try: - time.sleep(seconds) # setitimer may not be supported + with sleep_condition: + signal.setitimer(signal.ITIMER_REAL, seconds) + sleep_condition.wait() except KeyboardInterrupt: signal_SIGTERM(0, None) + except: + try: + time.sleep(seconds) # setitimer may not be supported + except KeyboardInterrupt: + signal_SIGTERM(0, None) ## Catch signals def signal_(sig, fun): -- cgit v1.2.3-70-g09d2