Skip to content

Commit

Permalink
bug: fix a bug where whatsminers could raise a cascading TimeoutError.
Browse files Browse the repository at this point in the history
  • Loading branch information
b-rowan committed Aug 25, 2024
1 parent a0daf37 commit 501e290
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pyasic/rpc/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,18 @@ async def _send_bytes(
return b"{}"

# send the command
data_task = asyncio.create_task(self._read_bytes(reader, timeout=timeout))
logging.debug(f"{self} - ([Hidden] Send Bytes) - Writing")
writer.write(data)
logging.debug(f"{self} - ([Hidden] Send Bytes) - Draining")
await writer.drain()

await data_task
ret_data = data_task.result()
try:
data_task = asyncio.create_task(self._read_bytes(reader, timeout=timeout))
logging.debug(f"{self} - ([Hidden] Send Bytes) - Writing")
writer.write(data)
logging.debug(f"{self} - ([Hidden] Send Bytes) - Draining")
await writer.drain()

await data_task
ret_data = data_task.result()
except TimeoutError:
logging.warning(f"{self} - ([Hidden] Send Bytes) - Read timeout expired.")
return b"{}"

# close the connection
logging.debug(f"{self} - ([Hidden] Send Bytes) - Closing")
Expand Down

0 comments on commit 501e290

Please sign in to comment.