Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIZNET5K can throw AssertionError for failing to configure DHCP #57

Closed
chabala opened this issue Apr 10, 2022 · 2 comments
Closed

WIZNET5K can throw AssertionError for failing to configure DHCP #57

chabala opened this issue Apr 10, 2022 · 2 comments

Comments

@chabala
Copy link
Contributor

chabala commented Apr 10, 2022

There's an open issue, #53 about failing to connect with DHCP, but that is about constantly failing, and I don't want to hijack it.

I recently had this happen:

code.py output:
starting...
Traceback (most recent call last):
  File "code.py", line 29, in <module>
  File "/lib/adafruit_wiznet5k/adafruit_wiznet5k.py", line 207, in __init__
AssertionError: Failed to configure DHCP Server!

Code done running.

This is new for me, as DHCP usually works, and I was testing code by having it run for hours unattended, and having it soft reset the board when it reached its success state. DHCP was back to working again when I restarted the program.

The code in adafruit_wiznet5k.py:

# Set DHCP
if is_dhcp:
ret = self.set_dhcp(hostname, dhcp_timeout)
if ret != 0:
self._dhcp_client = None
assert ret == 0, "Failed to configure DHCP Server!"

These are the last lines of the __init__ block for the WIZNET5K object. While failing to configure DHCP is not ideal, it's also not assertion worthy. It's calling set_dhcp() which has a timeout and return codes, so failure was an expected outcome.

The real issue here is throwing AssertionError for something that is not invariant; failures happen, this should raise an exception, and probably incorporate some retries first, but definitely not make any assertions.

The current user workaround to prevent hanging here would be to try...except AssertionError around constructing WIZNET5K, which is disappointing.

@FoamyGuy
Copy link
Contributor

The assertion has been removed and this raises a RuntimeError now. I believe that closes this issue.

Feel free to re-open if I've misunderstood and this issue still remains.

@chabala
Copy link
Contributor Author

chabala commented Jan 24, 2023

I agree, fixed by #85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants