forked from M-Labs/kirdy
async driver: fix incorrect timeout handling
This commit is contained in:
parent
67f9e65df8
commit
7f06fc06fd
|
@ -625,7 +625,7 @@ class Kirdy:
|
|||
async def _read_response(self):
|
||||
try:
|
||||
response = await asyncio.wait_for(self._reader.read(1024), self.timeout)
|
||||
except TimeoutError:
|
||||
except asyncio.exceptions.TimeoutError:
|
||||
return {
|
||||
"msg_type": "Internal Timeout"
|
||||
}
|
||||
|
@ -645,12 +645,10 @@ class Kirdy:
|
|||
self._writer.write(bytes(json.dumps(cmd), "UTF-8"))
|
||||
await self._writer.drain()
|
||||
response = await self._read_response()
|
||||
try:
|
||||
if response["msg_type"] == "Acknowledge":
|
||||
return response
|
||||
except:
|
||||
retry += 1
|
||||
await asyncio.sleep(0.25)
|
||||
if response["msg_type"] == "Acknowledge":
|
||||
return response
|
||||
retry += 1
|
||||
await asyncio.sleep(0.1)
|
||||
raise NoAckRecv
|
||||
|
||||
async def _send_cmd_handler(self, target, cmd, data=None):
|
||||
|
@ -681,12 +679,10 @@ class Kirdy:
|
|||
self._writer.write(bytes(json.dumps(cmd_dict), "UTF-8"))
|
||||
await self._writer.drain()
|
||||
response = await self._read_response()
|
||||
try:
|
||||
if response["msg_type"] == "Acknowledge":
|
||||
return response
|
||||
except:
|
||||
retry += 1
|
||||
await asyncio.sleep(0.1)
|
||||
if response["msg_type"] == "Acknowledge":
|
||||
return response
|
||||
retry += 1
|
||||
await asyncio.sleep(0.1)
|
||||
raise NoAckRecv
|
||||
|
||||
async def report_mode(self):
|
||||
|
|
Loading…
Reference in New Issue