Skip to content

Commit

Permalink
pre-commit is the new black
Browse files Browse the repository at this point in the history
  • Loading branch information
Neradoc committed Mar 29, 2022
1 parent f62cd13 commit 6bfa0f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
18 changes: 7 additions & 11 deletions adafruit_wiznet5k/adafruit_wiznet5k.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 4 additions & 8 deletions adafruit_wiznet5k/adafruit_wiznet5k_dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6bfa0f3

Please sign in to comment.