sleep_test network manager dbus listen code never exits if network manager doesn't reconnect
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Checkbox |
Fix Released
|
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
- Marc Tardif (community): Approve
-
Diff: 16 lines (+2/-1)1 file modifiedscripts/sleep_test (+2/-1)
Changed in checkbox: | |
status: | New → Confirmed |
Changed in checkbox: | |
importance: | Undecided → Low |
Changed in checkbox: | |
status: | In Progress → Fix Committed |
Changed in checkbox: | |
status: | Fix Committed → Fix Released |
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):