# Path: sts/util/convenience.py
# def find_port(port_spec):
#   if isinstance(port_spec, xrange):
#     port_spec = list(port_spec)
#   port_gen = None
#   if isinstance(port_spec, int):
#     def port_gen():
#       yield port_spec
#       raise Exception("Fixed port %d is busy. Consider specifying a range or a lambda " % port_spec)
#   elif isinstance(port_spec, list):
#     def port_gen():
#       cands = list(port_spec)
#       true_random.shuffle(cands)
#       for c in cands:
#         yield c
#       raise Exception("Port list/range %s exhausted" % str(port_spec))
#   elif isinstance(port_spec, types.FunctionType) or isinstance(port_spec, types.LambdaType):
#     port_gen = port_spec
# 
#   gen = port_gen()
#   for _ in range(0,100):
#     candidate = gen.next()
#     if not port_used(port=candidate):
#       return candidate
#   raise Exception("Could not find a port in 100 tries")


from abc import *
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
from sts.util.convenience import find_port
from pox.lib.util import connect_with_backoff
import os
import xmlrpclib
import sys
import marshal
import signal
import logging
      import traceback
    def invoke_child():
      try:
        return getattr(proxy, task_name)(*args)
      except xmlrpclib.Fault as e:
        raise ReplayException("An Exception (code %d) occured in the child replay process: %s" %
                              (e.faultCode, e.faultString))

    child_return = connect_with_backoff(invoke_child)
    # Magic to close the underlying socket. I'm not sure if this is actually
    # needed? See ServerProxy.__call__ in:
    # http://hg.python.org/cpython/file/2.7/Lib/xmlrpclib.py
    proxy("close")()
    log.debug("Completed task %s on child %s" % (task_name, child_url,))
    return child_return

  def _initialize_child_rpc_server(self, ip, port):
    # Called within the child process.
    # The child's RPC methods must registered through register_task()
    self.server = SimpleXMLRPCServer((ip, port), DebuggableHandler, allow_none=True,
                                     bind_and_activate=False)
    self.server.allow_reuse_address = True
    self.server.server_bind()
    self.server.server_activate()

class LocalForker(Forker):
  # set of process ids that are currently running. These are all killed upon
  # signal reception.
  _active_pids = set()

  @staticmethod

# Path: sts/util/convenience.py
# def find_port(port_spec):
#   if isinstance(port_spec, xrange):
#     port_spec = list(port_spec)
#   port_gen = None
#   if isinstance(port_spec, int):
#     def port_gen():
#       yield port_spec
#       raise Exception("Fixed port %d is busy. Consider specifying a range or a lambda " % port_spec)
#   elif isinstance(port_spec, list):
#     def port_gen():
#       cands = list(port_spec)
#       true_random.shuffle(cands)
#       for c in cands:
#         yield c
#       raise Exception("Port list/range %s exhausted" % str(port_spec))
#   elif isinstance(port_spec, types.FunctionType) or isinstance(port_spec, types.LambdaType):
#     port_gen = port_spec
# 
#   gen = port_gen()
#   for _ in range(0,100):
#     candidate = gen.next()
#     if not port_used(port=candidate):
#       return candidate
#   raise Exception("Could not find a port in 100 tries")


# Path: sts/util/rpc_forker.py
from abc import *
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
from sts.util.convenience import find_port
from pox.lib.util import connect_with_backoff
import os
import xmlrpclib
import sys
import marshal
import signal
import logging
      import traceback

    def invoke_child():
      try:
        return getattr(proxy, task_name)(*args)
      except xmlrpclib.Fault as e:
        raise ReplayException("An Exception (code %d) occured in the child replay process: %s" %
                              (e.faultCode, e.faultString))

    child_return = connect_with_backoff(invoke_child)
    # Magic to close the underlying socket. I'm not sure if this is actually
    # needed? See ServerProxy.__call__ in:
    # http://hg.python.org/cpython/file/2.7/Lib/xmlrpclib.py
    proxy("close")()
    log.debug("Completed task %s on child %s" % (task_name, child_url,))
    return child_return

  def _initialize_child_rpc_server(self, ip, port):
    # Called within the child process.
    # The child's RPC methods must registered through register_task()
    self.server = SimpleXMLRPCServer((ip, port), DebuggableHandler, allow_none=True,
                                     bind_and_activate=False)
    self.server.allow_reuse_address = True
    self.server.server_bind()
    self.server.server_activate()

class LocalForker(Forker):
  # set of process ids that are currently running. These are all killed upon
  # signal reception.
  _active_pids = set()

  @staticmethod

  def kill_all():