def spawn_processes(log, args): """ Launch the subprocesses and hang until completion. """ shared = SharedState() log.info("Spawning RPC process...") _PROCESSES.append( mpm.spawn_rpc_process(mpm.mpmtypes.MPM_RPC_PORT, shared, args.default_args)) log.debug("RPC process has PID: %d", _PROCESSES[-1].pid) if watchdog.has_watchdog(): watchdog.transfer_control(_PROCESSES[-1].pid) log.info("Spawning discovery process...") _PROCESSES.append(mpm.spawn_discovery_process(shared, args.discovery_addr)) log.debug("Discovery process has PID: %d", _PROCESSES[-1].pid) log.info("Processes launched. Registering signal handlers.") # Launch the kill thread # This is used because we cannot block in a signal handler, # meaning we cannot join threads Thread(target=kill_thread, daemon=False).start() signal.signal(signal.SIGTERM, kill_time) signal.signal(signal.SIGINT, kill_time) if JOIN_PROCESSES: for proc in _PROCESSES: proc.join() return True
def __init__(self, state, default_args): self.log = get_main_logger().getChild('RPCServer') self.log.trace("Launching RPC server with compat num %d.%d", MPM_COMPAT_NUM[0], MPM_COMPAT_NUM[1]) self._state = state self._timer = Greenlet() # Setting this to True will disable an unclaim on timeout. Use with # care, and make sure to set it to False again when finished. self._disable_timeouts = False self._timeout_interval = float( default_args.get("rpc_timeout_interval", TIMEOUT_INTERVAL)) self.session_id = None # Create the periph_manager for this device # This call will be forwarded to the device specific implementation # e.g. in periph_manager/n3xx.py # Which implementation is called will be determined during # configuration with cmake (-DMPM_DEVICE). # mgr is thus derived from PeriphManagerBase # (see periph_manager/base.py) from usrp_mpm.periph_manager import periph_manager self._mgr_generator = lambda: periph_manager(default_args) self.periph_manager = self._mgr_generator() device_info = self.periph_manager.get_device_info() self._state.dev_type.value = \ to_binary_str(device_info.get("type", "n/a")) self._state.dev_product.value = \ to_binary_str(device_info.get("product", "n/a")) self._state.dev_serial.value = \ to_binary_str(device_info.get("serial", "n/a")) self._state.dev_fpga_type.value = \ to_binary_str(device_info.get("fpga", "n/a")) self._db_methods = [] self._mb_methods = [] self.claimed_methods = copy.copy(self.default_claimed_methods) self._last_error = "" self._init_rpc_calls(self.periph_manager) # We call the server __init__ function here, and not earlier, because # first the commands need to be registered super(MPMServer, self).__init__( pack_params={'use_bin_type': True}, unpack_params={ 'max_buffer_size': 50000000, 'raw': False }, ) self._state.system_ready.value = True self.log.info("RPC server ready!") # Optionally spawn watchdog. Note: In order for us to be able to spawn # the task from this thread, the main process needs to hand control to # us using watchdog.transfer_control(). if watchdog.has_watchdog(): self.log.info("Spawning watchdog task...") watchdog.spawn_watchdog_task(self._state, self.log)
def __init__(self, state, default_args): self.log = get_main_logger().getChild('RPCServer') self.log.trace("Launching RPC server with compat num %d.%d", MPM_COMPAT_NUM[0], MPM_COMPAT_NUM[1]) self._state = state self._timer = Greenlet() # Setting this to True will disable an unclaim on timeout. Use with # care, and make sure to set it to False again when finished. self._disable_timeouts = False self._timeout_interval = float(default_args.get( "rpc_timeout_interval", TIMEOUT_INTERVAL )) self.session_id = None # Create the periph_manager for this device # This call will be forwarded to the device specific implementation # e.g. in periph_manager/n3xx.py # Which implementation is called will be determined during # configuration with cmake (-DMPM_DEVICE). # mgr is thus derived from PeriphManagerBase # (see periph_manager/base.py) from usrp_mpm.periph_manager import periph_manager self._mgr_generator = lambda: periph_manager(default_args) self.periph_manager = self._mgr_generator() device_info = self.periph_manager.get_device_info() self._state.dev_type.value = \ to_binary_str(device_info.get("type", "n/a")) self._state.dev_product.value = \ to_binary_str(device_info.get("product", "n/a")) self._state.dev_serial.value = \ to_binary_str(device_info.get("serial", "n/a")) self._db_methods = [] self._mb_methods = [] self.claimed_methods = copy.copy(self.default_claimed_methods) self._last_error = "" self._init_rpc_calls(self.periph_manager) # We call the server __init__ function here, and not earlier, because # first the commands need to be registered super(MPMServer, self).__init__( pack_params={'use_bin_type': True}, ) self._state.system_ready.value = True self.log.info("RPC server ready!") # Optionally spawn watchdog. Note: In order for us to be able to spawn # the task from this thread, the main process needs to hand control to # us using watchdog.transfer_control(). if watchdog.has_watchdog(): self.log.info("Spawning watchdog task...") watchdog.spawn_watchdog_task(self._state, self.log)
def spawn_processes(log, args): """ Launch the subprocesses and hang until completion. """ shared = SharedState() log.info("Spawning RPC process...") _PROCESSES.append( mpm.spawn_rpc_process(mpm.mpmtypes.MPM_RPC_PORT, shared, args.default_args)) log.debug("RPC process has PID: %d", _PROCESSES[-1].pid) if watchdog.has_watchdog(): watchdog.transfer_control(_PROCESSES[-1].pid) log.info("Spawning discovery process...") _PROCESSES.append(mpm.spawn_discovery_process(shared, args.discovery_addr)) log.debug("Discovery process has PID: %d", _PROCESSES[-1].pid) log.info("Processes launched. Registering signal handlers.") signal.signal(signal.SIGTERM, kill_time) signal.signal(signal.SIGINT, kill_time) for proc in _PROCESSES: proc.join() return True
def __init__(self, state, default_args): self.log = get_main_logger().getChild('RPCServer') self._state = state self._timer = Greenlet() self.session_id = None # Create the periph_manager for this device # This call will be forwarded to the device specific implementation # e.g. in periph_manager/n310.py # Which implementation is called will be determined during # configuration with cmake (-DMPM_DEVICE). # mgr is thus derived from PeriphManagerBase # (see periph_manager/base.py) from usrp_mpm.periph_manager import periph_manager self._mgr_generator = lambda: periph_manager(default_args) self.periph_manager = self._mgr_generator() device_info = self.periph_manager.get_device_info() self._state.dev_type.value = \ to_binary_str(device_info.get("type", "n/a")) self._state.dev_product.value = \ to_binary_str(device_info.get("product", "n/a")) self._state.dev_serial.value = \ to_binary_str(device_info.get("serial", "n/a")) self._db_methods = [] self._mb_methods = [] self.claimed_methods = copy.copy(self.default_claimed_methods) self._last_error = "" self._init_rpc_calls(self.periph_manager) # We call the server __init__ function here, and not earlier, because # first the commands need to be registered super(MPMServer, self).__init__( pack_params={'use_bin_type': True}, ) self._state.system_ready.value = True self.log.info("RPC server ready!") # Optionally spawn watchdog. Note: In order for us to be able to spawn # the task from this thread, the main process needs to hand control to # us using watchdog.transfer_control(). if watchdog.has_watchdog(): self.log.info("Spawning watchdog task...") watchdog.spawn_watchdog_task(self._state, self.log)
def spawn_processes(log, args): """ Launch the subprocesses and hang until completion. """ shared = SharedState() log.info("Spawning RPC process...") _PROCESSES.append( mpm.spawn_rpc_process( mpm.mpmtypes.MPM_RPC_PORT, shared, args.default_args)) log.debug("RPC process has PID: %d", _PROCESSES[-1].pid) if watchdog.has_watchdog(): watchdog.transfer_control(_PROCESSES[-1].pid) log.info("Spawning discovery process...") _PROCESSES.append( mpm.spawn_discovery_process(shared, args.discovery_addr) ) log.debug("Discovery process has PID: %d", _PROCESSES[-1].pid) log.info("Processes launched. Registering signal handlers.") signal.signal(signal.SIGTERM, kill_time) signal.signal(signal.SIGINT, kill_time) for proc in _PROCESSES: proc.join() return True