Skip to content

Commit

Permalink
Add timeout on close
Browse files Browse the repository at this point in the history
Adds additional timeout wait on socket close in __exit__

Corrects for occasional duplicate ACK packet that caused a 0 len message to be read.
  • Loading branch information
AdamCummick committed Jan 21, 2021
1 parent 2e00a87 commit 6bbc692
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions adafruit_wiznet5k/adafruit_wiznet5k_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def __exit__(self, exc_type, exc_val, exc_tb):
if time.monotonic() - stamp > 1000:
raise RuntimeError("Failed to disconnect socket")
self.close()
stamp = time.monotonic()
while self.status != adafruit_wiznet5k.SNSR_SOCK_CLOSED:
if time.monotonic() - stamp > 1000:
raise RuntimeError("Failed to close socket")

@property
def socknum(self):
Expand Down

0 comments on commit 6bbc692

Please sign in to comment.