def child_logic(args):
    'Able to be imported child logic.'
    import psutil
    from testplan.runners.pools.base import Pool, Worker
    from testplan.runners.pools.process import ProcessPool, ProcessWorker
    from testplan.runners.pools.connection import ZMQClient
    if args.log_level:
        from testplan.common.utils.logger import TESTPLAN_LOGGER, STDOUT_HANDLER
        TESTPLAN_LOGGER.setLevel(args.log_level)
        TESTPLAN_LOGGER.removeHandler(STDOUT_HANDLER)
    print('Starting child process worker on {}, {} with parent {}'.format(socket.gethostname(), os.getpid(), psutil.Process(os.getpid()).ppid()))
    if args.runpath:
        print('Removing old runpath: {}'.format(args.runpath))
        shutil.rmtree(args.runpath, ignore_errors=True)

    class NoRunpathPool(Pool):
        '\n        Pool that creates no runpath directory.\n        Has only one worker.\n        Will use the one already created by parent process.\n        '

        def make_runpath_dirs(self):
            self._runpath = self.cfg.runpath

    class NoRunpathThreadPool(Pool):
        '\n        Pool that creates no runpath directory.\n        Will use the one already created by parent process.\n        Supports multiple thread workers.\n        '

        def make_runpath_dirs(self):
            self._runpath = self.cfg.runpath

    class NoRunpathProcessPool(ProcessPool):
        '\n        Pool that creates no runpath directory.\n        Will use the one already created by parent process.\n        Supports multiple process workers.\n        '

        def make_runpath_dirs(self):
            self._runpath = self.cfg.runpath
    transport = ZMQClient(address=args.address, recv_timeout=30)
    if (args.type == 'process_worker'):
        loop = ChildLoop(args.index, transport, NoRunpathPool, 1, Worker, TESTPLAN_LOGGER)
        loop.worker_loop()
    elif (args.type == 'remote_worker'):
        if (args.remote_pool_type == 'process'):
            pool_type = NoRunpathProcessPool
            worker_type = ProcessWorker
        else:
            pool_type = NoRunpathThreadPool
            worker_type = Worker
        loop = RemoteChildLoop(args.index, transport, pool_type, args.remote_pool_size, worker_type, TESTPLAN_LOGGER, runpath=args.runpath)
        loop.worker_loop()
Able to be imported child logic.
def child_logic(args):
    
    import psutil
    from testplan.runners.pools.base import Pool, Worker
    from testplan.runners.pools.process import ProcessPool, ProcessWorker
    from testplan.runners.pools.connection import ZMQClient
    if args.log_level:
        from testplan.common.utils.logger import TESTPLAN_LOGGER, STDOUT_HANDLER
        TESTPLAN_LOGGER.setLevel(args.log_level)
        TESTPLAN_LOGGER.removeHandler(STDOUT_HANDLER)
    print('Starting child process worker on {}, {} with parent {}'.format(socket.gethostname(), os.getpid(), psutil.Process(os.getpid()).ppid()))
    if args.runpath:
        print('Removing old runpath: {}'.format(args.runpath))
        shutil.rmtree(args.runpath, ignore_errors=True)

    class NoRunpathPool(Pool):
        '\n        Pool that creates no runpath directory.\n        Has only one worker.\n        Will use the one already created by parent process.\n        '

        def make_runpath_dirs(self):
            self._runpath = self.cfg.runpath

    class NoRunpathThreadPool(Pool):
        '\n        Pool that creates no runpath directory.\n        Will use the one already created by parent process.\n        Supports multiple thread workers.\n        '

        def make_runpath_dirs(self):
            self._runpath = self.cfg.runpath

    class NoRunpathProcessPool(ProcessPool):
        '\n        Pool that creates no runpath directory.\n        Will use the one already created by parent process.\n        Supports multiple process workers.\n        '

        def make_runpath_dirs(self):
            self._runpath = self.cfg.runpath
    transport = ZMQClient(address=args.address, recv_timeout=30)
    if (args.type == 'process_worker'):
        loop = ChildLoop(args.index, transport, NoRunpathPool, 1, Worker, TESTPLAN_LOGGER)
        loop.worker_loop()
    elif (args.type == 'remote_worker'):
        if (args.remote_pool_type == 'process'):
            pool_type = NoRunpathProcessPool
            worker_type = ProcessWorker
        else:
            pool_type = NoRunpathThreadPool
            worker_type = Worker
        loop = RemoteChildLoop(args.index, transport, pool_type, args.remote_pool_size, worker_type, TESTPLAN_LOGGER, runpath=args.runpath)
        loop.worker_loop()