Python code when you start from PyCharm without a debugger attached behaves differently than when you start with pydev.
I run the POX SDN controller in PyCharm and Mininet from a console that connects a listening socket opened by POX. When starting in debug mode, the POX process ends as soon as the Mininet simulation connects to it without any errors, while it continues to work as expected in start mode. Here is the result:
Run:
/usr/bin/python2.7 /home/wirate/pyretic/pyretic.py pyretic.sdx.main Initialize SDX SDX: {'_policy': drop, 'notify': None, 'arp_policy': [DynamicPolicy] packets FwdBucket} Creating SDX environment from the config files Adding Physical ports for A Adding virtual ports for A Adding Physical ports for C Adding virtual ports for C Adding Physical ports for B Adding virtual ports for B {u'A': {u'A': [1], u'C': [3], u'B': [2]}, u'C': {u'C': [3, 4]}, u'B': {u'B': [2]}} {u'A': {u'A': [1], u'C': [3], u'B': [2]}, u'C': {u'A': [1], u'C': [3, 4], u'B': [2]}, u'B': {u'B': [2]}} {u'A': {u'A': [1], u'C': [3], u'B': [2]}, u'C': {u'A': [1], u'C': [3, 4], u'B': [2]}, u'B': {u'A': [1], u'C': [3], u'B': [2]}} Parsing participant policies Starting VNH Assignment After new assignment Virtual Next Hop --> IP Prefix: {'VNH1': set([u'110.0.0.0/24', u'100.0.0.0/24']), 'VNH2': set([u'140.0.0.0/24', u'150.0.0.0/24'])} Virtual Next Hop --> Next Hop IP Address (Virtual): {'VNH1': '172.0.1.1', 'VNH2': '172.0.1.2', 'VNH': [IPAddress('172.0.1.0'), IPAddress('172.0.1.1'), IPAddress('172.0.1.2'), IPAddress('172.0.1.3'), IPAddress('172.0.1.4'), IPAddress('172.0.1.5'), IPAddress('172.0.1.6'), IPAddress('172.0.1.7'), IPAddress('172.0.1.8'), IPAddress('172.0.1.9'), IPAddress('172.0.1.10'), IPAddress('172.0.1.11'), IPAddress('172.0.1.12'), IPAddress('172.0.1.13'), IPAddress('172.0.1.14'), IPAddress('172.0.1.15')]} Virtual Next Hop --> Next Hop Mac Address (Virtual) {'VNH1': aa:00:00:00:00:01, 'VNH2': aa:00:00:00:00:02, 'VNH': 'aa:00:00:00:00:00'} Completed VNH Assignment POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al. Connected to pyretic frontend. DEBUG:core:POX 0.2.0 (carp) going up... DEBUG:core:Running on CPython (2.7.8/Oct 20 2014 15:05:19) DEBUG:core:Platform is Linux-3.16.0-24-generic-x86_64-with-Ubuntu-14.10-utopic INFO:core:POX 0.2.0 (carp) is up. DEBUG:openflow.of_01:Listening on 0.0.0.0:6633 INFO:openflow.of_01:[00-00-00-00-00-01 1] connected
Debug:
/usr/bin/python2.7 /home/wirate/pycharm-4.0/helpers/pydev/pydevd.py --multiproc --client 127.0.0.1 --port 49196 --file /home/wirate/pyretic/pyretic.py pyretic.sdx.main pydev debugger: process 5555 is connecting Connected to pydev debugger (build 139.574) Initialize SDX SDX: {'_policy': drop, 'notify': None, 'arp_policy': [DynamicPolicy] packets FwdBucket} Creating SDX environment from the config files Adding Physical ports for A Adding virtual ports for A Adding Physical ports for C Adding virtual ports for C Adding Physical ports for B Adding virtual ports for B {u'A': {u'A': [1], u'C': [3], u'B': [2]}, u'C': {u'C': [3, 4]}, u'B': {u'B': [2]}} {u'A': {u'A': [1], u'C': [3], u'B': [2]}, u'C': {u'A': [1], u'C': [3, 4], u'B': [2]}, u'B': {u'B': [2]}} {u'A': {u'A': [1], u'C': [3], u'B': [2]}, u'C': {u'A': [1], u'C': [3, 4], u'B': [2]}, u'B': {u'A': [1], u'C': [3], u'B': [2]}} Parsing participant policies Starting VNH Assignment After new assignment Virtual Next Hop --> IP Prefix: {'VNH1': set([u'110.0.0.0/24', u'100.0.0.0/24']), 'VNH2': set([u'140.0.0.0/24', u'150.0.0.0/24'])} Virtual Next Hop --> Next Hop IP Address (Virtual): {'VNH1': '172.0.1.1', 'VNH2': '172.0.1.2', 'VNH': [IPAddress('172.0.1.0'), IPAddress('172.0.1.1'), IPAddress('172.0.1.2'), IPAddress('172.0.1.3'), IPAddress('172.0.1.4'), IPAddress('172.0.1.5'), IPAddress('172.0.1.6'), IPAddress('172.0.1.7'), IPAddress('172.0.1.8'), IPAddress('172.0.1.9'), IPAddress('172.0.1.10'), IPAddress('172.0.1.11'), IPAddress('172.0.1.12'), IPAddress('172.0.1.13'), IPAddress('172.0.1.14'), IPAddress('172.0.1.15')]} Virtual Next Hop --> Next Hop Mac Address (Virtual) {'VNH1': aa:00:00:00:00:01, 'VNH2': aa:00:00:00:00:02, 'VNH': 'aa:00:00:00:00:00'} Completed VNH Assignment pydev debugger: process 5595 is connecting POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al. POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al. Connected to pyretic frontend. DEBUG:core:POX 0.2.0 (carp) going up... DEBUG:core:Running on CPython (2.7.8/Oct 20 2014 15:05:19) DEBUG:core:Platform is Linux-3.16.0-24-generic-x86_64-with-Ubuntu-14.10-utopic INFO:core:POX 0.2.0 (carp) is up. DEBUG:openflow.of_01:Listening on 0.0.0.0:6633 INFO:openflow.of_01:[None 1] closed INFO:openflow.of_01:[00-00-00-00-00-01 2] connected Process finished with exit code 137
This is the code that starts the controller:
def main(): global of_client (op, options, args, kwargs_to_pass) = parseArgs() if options.mode == 'i': options.mode = 'interpreted' elif options.mode == 'r0': options.mode = 'reactive0' elif options.mode == 'p0': options.mode = 'proactive0' elif options.mode == 'p1': options.mode = 'proactive1' try: module_name = args[0] except IndexError: print 'Module must be specified' print '' op.print_usage() sys.exit(1) try: module = import_module(module_name) except ImportError, e: print 'Must be a valid python module' print 'eg, full module name,' print ' no .py suffix,' print ' located on the system PYTHONPATH' print '' print 'Exception message for ImportError was:' print e sys.exit(1) main = module.main kwargs = { k : v for [k,v] in [ i.lstrip('--').split('=') for i in kwargs_to_pass ]} sys.setrecursionlimit(1500)
Maybe I should add that I'm running PyCharm as root because privileges are required to run the controller.