Sorry, this patch is invalid, ignore it
On 06/29/2015 03:35 PM, Jiri Prochazka wrote:
When Slave is using NetworkManager, polling is used to activate DBus
connection.
This may result in infinite loop (eg. when device is not in LOWER_UP state, but is in UP
state).
This patch adds timeout control in _poll_loop method, timeout value is set to 10s.
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Slave/NmConfigDevice.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py
index 8e2f1dd..82e0cb8 100644
--- a/lnst/Slave/NmConfigDevice.py
+++ b/lnst/Slave/NmConfigDevice.py
@@ -153,10 +153,14 @@ class NmConfigDeviceGeneric(object):
self._loop.quit()
def _poll_loop(self, func, expected_val, *args):
- while True:
+ timer = 0
+ while timer < 10:
if func(*args) == expected_val:
break
time.sleep(1)
+ timer += 1
+ msg = "Timed out during NetworkManager polling."
+ raise Exception(msg)
def _convert_hwaddr(self, dev_config):
if "hwaddr" in dev_config: