summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--si7021d8
1 files changed, 6 insertions, 2 deletions
diff --git a/si7021d b/si7021d
index 123fc39..2a1e6c6 100644
--- a/si7021d
+++ b/si7021d
@@ -38,8 +38,12 @@ async def handle_client(reader, writer):
break
if request == 'read':
- rh, temp = await si7021_read()
- data = dict(humidity=rh, temp=temp)
+ try:
+ rh, temp = await asyncio.wait_for(si7021_read(), timeout=3)
+ data = dict(humidity=rh, temp=temp)
+ except asyncio.TimeoutError as e:
+ logger.exception(e)
+ data = dict(error='i2c call timed out')
else:
data = dict(error='invalid request')