changeset 13:4c81182eaa6b

daemon: Fail less ungracefully, bump to v0.1.0.
author Paul Fisher <paul@pfish.zone>
date Sun, 29 Sep 2019 12:11:16 -0400
parents 91e22a09b82f
children c01f9929ae38
files setup.py weatherlog/daemon.py
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Sun Sep 29 11:53:35 2019 -0400
+++ b/setup.py	Sun Sep 29 12:11:16 2019 -0400
@@ -2,7 +2,7 @@
 
 setuptools.setup(
     name='weatherlog',
-    version='0.0.1',
+    version='0.1.0',
     packages=setuptools.find_packages(),
     python_requires='>=3.7',
     install_requires=[
--- a/weatherlog/daemon.py	Sun Sep 29 11:53:35 2019 -0400
+++ b/weatherlog/daemon.py	Sun Sep 29 12:11:16 2019 -0400
@@ -25,9 +25,12 @@
     r = reader.DHT22Reader()
     cycle = 0
     start = time.time()
-    while True:
-        log.write(r.read())
-        cycle += 1
-        target = start + interval * cycle
-        now = time.time()
-        time.sleep(max(target - now, MIN_INTERVAL_SECS))
+    try:
+        while True:
+            log.write(r.read())
+            cycle += 1
+            target = start + interval * cycle
+            now = time.time()
+            time.sleep(max(target - now, MIN_INTERVAL_SECS))
+    finally:
+        log.close()