Fix for PONSIM exit issue with execption
Change-Id: Id249cb67760c8aa5708dccca63b60f06608d4900
diff --git a/common/frameio/frameio.py b/common/frameio/frameio.py
index 4ed999e..544d462 100644
--- a/common/frameio/frameio.py
+++ b/common/frameio/frameio.py
@@ -416,3 +416,12 @@
break # break inner loop so we reconstruct sockets list
log.debug('select-loop-exited')
+
+ def del_interface(self, iface_name):
+ """
+ Delete interface for stopping
+ """
+
+ log.info('Delete interface')
+ del self.ports[iface_name]
+ log.info('Interface(port) is deleted')
diff --git a/ponsim/main.py b/ponsim/main.py
index f3d0ffd..3e32d3a 100755
--- a/ponsim/main.py
+++ b/ponsim/main.py
@@ -174,11 +174,11 @@
"""Execute before the reactor is shut down"""
self.log.info('exiting-on-keyboard-interrupt')
if self.io is not None:
- self.io.stop()
+ yield self.io.stop()
self.teardown_networking_assets(self.args.name, self.args.onus)
if self.grpc_server is not None:
yield self.grpc_server.stop()
-
+
def start_reactor(self):
from twisted.internet import reactor
reactor.callWhenRunning(
diff --git a/ponsim/realio.py b/ponsim/realio.py
index 84d08ba..4e467f8 100644
--- a/ponsim/realio.py
+++ b/ponsim/realio.py
@@ -42,12 +42,16 @@
log.info('started')
returnValue(self)
+ @inlineCallbacks
def stop(self):
log.debug('stopping')
- for port in self.io_ports.values():
- self.frame_io.del_interface(port.iface_name)
- self.frame_io.stop()
- log.info('stopped')
+ try:
+ for port in self.io_ports.values():
+ yield self.frame_io.del_interface(port.iface_name)
+ yield self.frame_io.stop()
+ log.info('stopped')
+ except Exception, e:
+ log.info('exception: %r' % e)
def register_ponsim(self, ponsim):
self.ponsim = ponsim