Mercurial > code > home > repos > sensor-bridge
comparison sensor_bridge.py @ 1:087b57dd3587 default tip
if dimcurve request times out, abort so we get its new address
author | drewp@bigasterisk.com |
---|---|
date | Sat, 14 Dec 2024 21:39:44 -0800 |
parents | 62cca1da7955 |
children |
comparison
equal
deleted
inserted
replaced
0:62cca1da7955 | 1:087b57dd3587 |
---|---|
17 def faderValueUrl(faderName: str): | 17 def faderValueUrl(faderName: str): |
18 return f'http://{DIMCURVE_SERVICE_HOST}/dimcurve/api/faders/{faderName}/value' | 18 return f'http://{DIMCURVE_SERVICE_HOST}/dimcurve/api/faders/{faderName}/value' |
19 | 19 |
20 | 20 |
21 async def sendValue(faderName: str, value: float): | 21 async def sendValue(faderName: str, value: float): |
22 await httpClient.put(faderValueUrl(faderName), content=str(value).encode('ascii')) | 22 try: |
23 await httpClient.put(faderValueUrl(faderName), content=str(value).encode('ascii'), timeout=2) | |
24 except Exception: | |
25 log.warning("put failed - restarting service", exc_info=True) | |
26 os.abort() | |
23 | 27 |
24 | 28 |
25 async def onMessage(message): | 29 async def onMessage(message): |
26 log.info(f'{message.topic}: {message.payload}') | 30 log.info(f'{message.topic}: {message.payload}') |
27 payloadMap = { | 31 payloadMap = { |