def launch_modules_with_names(modules_with_names, module_args={}, kill_before_launch=True):
    '''launch module.main functions in another process'''
    processes = []
    if kill_before_launch:
        for module_name, name in modules_with_names:
            kill_module(name)
    for module_name, name in modules_with_names:
        m = importlib.import_module(module_name)
        args = {}
        if module_name in module_args:
            args = module_args[module_name]
        p1 = Process(target=m.main, args=args)
        p1.daemon = True
        p1.start()
        processes.append(p1)
        with open(get_launched_module_pid_file(name), 'w') as f:
            f.write('{}'.format(p1.pid))
    return processes
def launch_modules_with_names ( modules_with_names , module_args = { } , kill_before_launch = True ) : processes = [ ] if kill_before_launch : for module_name , name in modules_with_names : kill_module ( name ) for module_name , name in modules_with_names : m = importlib . import_module ( module_name ) args = { } if module_name in module_args : args = module_args [ module_name ] p1 = Process ( target = m . main , args = args ) p1 . daemon = True p1 . start ( ) processes . append ( p1 ) with open ( get_launched_module_pid_file ( name ) , 'w' ) as f : f . write ( '{}' . format ( p1 . pid ) ) return processes
launch module.main functions in another process