Skip to content

Commit 6bbc692

Browse files
committed
Add timeout on close
Adds additional timeout wait on socket close in __exit__ Corrects for occasional duplicate ACK packet that caused a 0 len message to be read.
1 parent 2e00a87 commit 6bbc692

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_socket.py

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ def __exit__(self, exc_type, exc_val, exc_tb):
118118
if time.monotonic() - stamp > 1000:
119119
raise RuntimeError("Failed to disconnect socket")
120120
self.close()
121+
stamp = time.monotonic()
122+
while self.status != adafruit_wiznet5k.SNSR_SOCK_CLOSED:
123+
if time.monotonic() - stamp > 1000:
124+
raise RuntimeError("Failed to close socket")
121125

122126
@property
123127
def socknum(self):

0 commit comments

Comments
 (0)