sleep_test network manager dbus listen code never exits if network manager doesn't reconnect

Bug #665299 reported by Jeff Lane on 2010-10-22
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Checkbox
Low
Brendan Donegan

Bug Description

Code was added to the sleep_test script that checks network manager to see if network manager has reconnected after a suspend or hibernate.

This works fine if there is a cable plugged in or a wi-fi connection set to autoconnect. However, in cases where the network connection is not set to autoconnect, this code goes to sleep and never wakes up, causing the sleep_test script to just sit there forever.

The code in question is this:

340 while True:
341 if nm.get_state() == nm.STATE_CONNECTED:
342 return True
343 # give 60 seconds to NetworkManager to get to a CONNECTED state, then give up
344 if datetime.now() - start > timedelta(60):
345 return False
346 sleep(5)

without digging in too deep, this loop DOES work as long as a connection is re-established at some point, however, it does not exit after 60 seconds giving the appearance that the test script is hung.

Related branches

Jeff Lane (bladernr) on 2010-10-22
Changed in checkbox:
status: New → Confirmed
Changed in checkbox:
importance: Undecided → Low

Oh it does exit eventually - after 60 days :)

Yeah, I debugged through this and found that constructing a timedelta with timedelta(60) for example takes the 60 to mean days by default. Merge request is on its way but the simple solution is:

if datetime.now() - start > timedelta(seconds=60):

Changed in checkbox:
status: Confirmed → In Progress
assignee: nobody → Brendan Donegan (brendan-donegan)
Marc Tardif (cr3) on 2011-06-06
Changed in checkbox:
status: In Progress → Fix Committed
Changed in checkbox:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers