summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-25 09:20:23 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-25 09:20:23 +0100
commitd392bb7be00170002741098d826f77473552f914 (patch)
tree722f5b88e1510d3c5d56371af93983f0f44e7d86 /src
parentmost of bedtime example (diff)
downloadblueshift-d392bb7be00170002741098d826f77473552f914.tar.gz
blueshift-d392bb7be00170002741098d826f77473552f914.tar.bz2
blueshift-d392bb7be00170002741098d826f77473552f914.tar.xz
Appearently we can interrupt datetime.datetime.now
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rwxr-xr-xsrc/__main__.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/__main__.py b/src/__main__.py
index 1da6f96..804b68c 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -259,6 +259,12 @@ def continuous_run():
time.sleep(seconds) # setitimer may not be supported
except KeyboardInterrupt:
signal_SIGTERM(0, None)
+ def now():
+ while True:
+ try:
+ return datetime.datetime.now()
+ except KeyboardInterrupt:
+ signal_SIGTERM(0, None)
## Catch signals
def signal_(sig, fun):
@@ -278,7 +284,7 @@ def continuous_run():
while running:
if trans_delta == 0:
## Run periodically
- p(datetime.datetime.now(), None)
+ p(now(), None)
if running:
sleep(wait_period)
elif trans_delta < 0:
@@ -287,13 +293,13 @@ def continuous_run():
fadein_time = None
if not ((fadein_time is None) or panicgate):
if trans_alpha == 0:
- p(datetime.datetime.now(), 1 - trans_alpha)
+ p(now(), 1 - trans_alpha)
sleep(fadein_time / fadein_steps)
trans_alpha -= 1 / fadein_steps
if (trans_alpha <= 0) or (fadein_time is None) or panicgate:
trans_alpha = 0
trans_delta = 0
- p(datetime.datetime.now(), 1 - trans_alpha)
+ p(now(), 1 - trans_alpha)
if fadein_time is not None:
sleep(fadein_time / fadein_steps)
else:
@@ -304,7 +310,7 @@ def continuous_run():
trans_alpha += 1 / fadeout_steps
if (trans_alpha >= 1) or (fadeout_time is None):
trans_alpha = 1
- p(datetime.datetime.now(), -1 + trans_alpha)
+ p(now(), -1 + trans_alpha)
if trans_alpha == 1:
try:
with sleep_condition:
@@ -324,7 +330,7 @@ def continuous_run():
if (trans_alpha >= 1) or (fadeout_time is None):
trans_alpha = 1
panic = True
- p(datetime.datetime.now(), -1 + trans_alpha)
+ p(now(), -1 + trans_alpha)
sleep(fadeout_time / fadeout_steps)
## Reset