# HG changeset patch # User Paul Fisher # Date 1569773476 14400 # Node ID 4c81182eaa6b06696f3d0351f5aff4b9848df5e6 # Parent 91e22a09b82fa3da4d67c097898070315daac7de daemon: Fail less ungracefully, bump to v0.1.0. diff -r 91e22a09b82f -r 4c81182eaa6b setup.py --- 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=[ diff -r 91e22a09b82f -r 4c81182eaa6b weatherlog/daemon.py --- 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()