Skip to content
Discussion options

You must be logged in to vote

You are calling init_ethernet() from inside itself, hence the recursion.
A simple loop will use way less resources, e..g.

have_network = False
while not have_network:
    try:
        # Keep track of number of attempts
        global connection_attempts
        connection_attempts += 1
        print(f'Connecting... attempt: {connection_attempts}')
        # Try nic.active takes 17-18 seconds
        nic.active(True)                                        
        have_network = True
        
    except OSError as error:
        now = time.localtime()
        print(f'Connection error: {error}, {now[3]:02d}:{now[4]:02d}:{now[5]:02d}')
        # In case of connection error, run this function…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@MrTinkerman
Comment options

Answer selected by MrTinkerman
Comment options

You must be logged in to vote
1 reply
@MrTinkerman
Comment options

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