fix
This commit is contained in:
parent
aa912e0dc2
commit
69da1a797a
12
main.py
12
main.py
@ -38,7 +38,7 @@ async def handle_client(reader, writer):
|
||||
except Exception:
|
||||
break
|
||||
|
||||
data = None
|
||||
data = 'unknown'
|
||||
if request == 'on':
|
||||
await relay_set(ON)
|
||||
logger.info('set on')
|
||||
@ -54,9 +54,15 @@ async def handle_client(reader, writer):
|
||||
data = 'on' if status is True else 'off'
|
||||
|
||||
writer.write((data + '\r\n').encode('utf-8'))
|
||||
await writer.drain()
|
||||
try:
|
||||
await writer.drain()
|
||||
except ConnectionError:
|
||||
break
|
||||
|
||||
writer.close()
|
||||
try:
|
||||
writer.close()
|
||||
except ConnectionError:
|
||||
pass
|
||||
|
||||
|
||||
async def run_server(host, port):
|
||||
|
Loading…
x
Reference in New Issue
Block a user