async def _recv_messages(self): try: # Notify parent proc that this proc is ready self.log.debug("reactorcore notifying main proc of ready") self.socket.send(CHILD_RDY_SIG) self.log.info( "-- Daemon proc listening to main proc on PAIR Socket at {} --" .format(self.url)) while True: self.log.debug( "ReactorDaemon awaiting for command from main thread...") cmd_bin = await self.socket.recv() self.log.debug("Got cmd from queue: {}".format(cmd_bin)) if cmd_bin == KILL_SIG: self.log.debug( "Daemon Process got kill signal from main proc") self._teardown() return # Should from_bytes be in a try/catch? I suppose if we get a bad command from the main proc we might as well # blow up because this is very likely because of a development error, so no try/catch for now cmd = ReactorCommand.from_bytes(cmd_bin) assert cmd.class_name and cmd.func_name, "Received invalid command with no class/func name!" self._execute_cmd(cmd) except asyncio.CancelledError: self.log.warning("some ish got cacnelerd")
async def _recv_messages(self): """ Should be for internal use only. Starts listening to messages from the ReactorDaemon. This method gets run_until_complete by invoking .start_reactor on the ReactorInterface object. """ try: self.log.debug( "~~ Reactor listening to messages from ReactorDaemon ~~") while True: self.log.debug("Waiting for callback...") msg = await self.socket.recv() callback = ReactorCommand.from_bytes(msg) self.log.debug("Got callback cmd <{}>".format(callback)) self.router.route_callback(callback) except asyncio.CancelledError: self.log.debug("_recv_messages future canceled!")
async def _recv_messages(self): # Notify parent proc that this proc is ready self.log.debug("reactorcore notifying main proc of ready") self.socket.send(CHILD_RDY_SIG) self.log.info( "-- Daemon proc listening to main proc on PAIR Socket at {} --". format(self.url)) while True: self.log.debug( "ReactorDaemon awaiting for command from main thread...") cmd_bin = await self.socket.recv() self.log.debug("Got cmd from queue: {}".format(cmd_bin)) if cmd_bin == KILL_SIG: self._teardown() return # Should from_bytes be in a try/catch? I suppose if we get a bad command from the main proc we might as well # blow up because this is very likely because of a development error, so no try/catch for now cmd = ReactorCommand.from_bytes(cmd_bin) await self._execute_cmd(cmd)