fix --twait (#1040)

- pass timeout correctly to waitConnected()
- handle surprising behavior that 1 == True in Python
- mn --test none does not call waitConnected()
This commit is contained in:
lantz
2021-02-09 11:26:39 -08:00
committed by GitHub
parent f8e54cad47
commit 5ef6e1dedc
2 changed files with 11 additions and 6 deletions
+6 -4
View File
@@ -183,8 +183,11 @@ class Mininet( object ):
delay: seconds to sleep per iteration
returns: True if all switches are connected"""
info( '*** Waiting for switches to connect\n' )
time = 0
time = 0.0
remaining = list( self.switches )
# False: 0s timeout; None: wait forever (preserve 2.2 behavior)
if isinstance( timeout, bool ):
timeout = None if timeout else 0
while True:
for switch in tuple( remaining ):
if switch.connected():
@@ -193,8 +196,7 @@ class Mininet( object ):
if not remaining:
info( '\n' )
return True
# Still allow None to preserve 2.2 behavior
if timeout not in ( None, True ) and time > timeout:
if timeout is not None and time >= timeout:
break
sleep( delay )
time += delay
@@ -561,7 +563,7 @@ class Mininet( object ):
started.update( { s: s for s in success } )
info( '\n' )
if self.waitConn:
self.waitConnected()
self.waitConnected( self.waitConn )
def stop( self ):
"Stop the controller(s), switches and hosts"