diff --git a/mininet/net.py b/mininet/net.py index 01e1936..d59a089 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -495,20 +495,25 @@ class Mininet( object ): if self.terms: info( '*** Stopping %i terms\n' % len( self.terms ) ) self.stopXterms() - info( '*** Stopping %i switches\n' % len( self.switches ) ) - for swclass, switches in groupby( - sorted( self.switches, key=type ), type ): - if hasattr( swclass, 'batchShutdown' ): - swclass.batchShutdown( switches ) - for switch in self.switches: - info( switch.name + ' ' ) - switch.stop() - switch.terminate() - info( '\n' ) info( '*** Stopping %i links\n' % len( self.links ) ) for link in self.links: + info( '.' ) link.stop() info( '\n' ) + info( '*** Stopping %i switches\n' % len( self.switches ) ) + stopped = {} + for swclass, switches in groupby( + sorted( self.switches, key=type ), type ): + switches = tuple( switches ) + if hasattr( swclass, 'batchShutdown' ): + swclass.batchShutdown( switches ) + stopped.update( { s: s for s in switches } ) + for switch in self.switches: + info( switch.name + ' ' ) + if switch not in stopped: + switch.stop() + switch.terminate() + info( '\n' ) info( '*** Stopping %i hosts\n' % len( self.hosts ) ) for host in self.hosts: info( host.name + ' ' )