diff --git a/adafruit_wiznet5k/adafruit_wiznet5k.py b/adafruit_wiznet5k/adafruit_wiznet5k.py index acb82ff..f858d14 100644 --- a/adafruit_wiznet5k/adafruit_wiznet5k.py +++ b/adafruit_wiznet5k/adafruit_wiznet5k.py @@ -841,17 +841,13 @@ def socket_write(self, socket_num, buffer, timeout=0): while ( self._read_socket(socket_num, REG_SNIR)[0] & SNIR_SEND_OK ) != SNIR_SEND_OK: - if ( - self.socket_status(socket_num)[0] - in ( - SNSR_SOCK_CLOSED, - SNSR_SOCK_TIME_WAIT, - SNSR_SOCK_FIN_WAIT, - SNSR_SOCK_CLOSE_WAIT, - SNSR_SOCK_CLOSING, - ) - or (timeout and time.monotonic() - stamp > timeout) - ): + if self.socket_status(socket_num)[0] in ( + SNSR_SOCK_CLOSED, + SNSR_SOCK_TIME_WAIT, + SNSR_SOCK_FIN_WAIT, + SNSR_SOCK_CLOSE_WAIT, + SNSR_SOCK_CLOSING, + ) or (timeout and time.monotonic() - stamp > timeout): # self.socket_close(socket_num) return 0 time.sleep(0.01) diff --git a/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py b/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py index 513f9a4..edb3e19 100644 --- a/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py +++ b/adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py @@ -472,14 +472,10 @@ def _dhcp_state_machine(self): if self._debug: print("* DHCP: Time to renew lease") - if ( - self._dhcp_state - in ( - STATE_DHCP_DISCOVER, - STATE_DHCP_REQUEST, - ) - and time.monotonic() > (self._start_time + self._response_timeout) - ): + if self._dhcp_state in ( + STATE_DHCP_DISCOVER, + STATE_DHCP_REQUEST, + ) and time.monotonic() > (self._start_time + self._response_timeout): self._dhcp_state = STATE_DHCP_WAIT if self._sock is not None: self._sock.close()