def _recv_command(self,block=False): if not block and not self.pipe.poll(): return try: logger.debug(msg("Receiving from pipe")) command = self.pipe.recv() logger.debug(msg("Got command ", command.message_name, " priority = ", command.priority)) _insert_sorted(self.command_queue, command, self._compute_priority(command)) logger.debug(msg("Saved command ", command.message_name, " priority = ", command.priority)) except Exception, e: logger.error(msg("Error when receiving command:", e))
ret = method(*command.args, **command.kwargs) response = rpc( command.message_name, ret, response_to = call_id, rpc_type = rpc.OBJECT_MESSAGE_RESPONSE ) self.pipe.send(response) except Exception, e: logger.warn(msg("Exception while running command ", command.message_name, " exception == ", e)) response = rpc( 'error', response_to = call_id, rpc_type = rpc.ERROR_MESSAGE) response.error_typ = 'exception' try: response.error_description = str(e) except: pass response.exception = e self.pipe.send(response) else: logger.debug(msg("Saving command ", command.message_name, " priority = ", command.priority)) _insert_sorted(self.command_queue, command, command.priority) logger.debug(msg("Saved command ", command.message_name, " priority = ", command.priority)) def _sendError(self, *args, **kwargs): command = rpc( 'error', *args, **kwargs) command.rpc_type = rpc.ERROR_MESSAGE self.pipe.send(command) def _recv_command(self,block=False): if not block and not self.pipe.poll(): return try: logger.debug(msg("Receiving from pipe")) command = self.pipe.recv() logger.debug(msg("Got command ", command.message_name, " priority = ", command.priority)) _insert_sorted(self.command_queue, command, self._compute_priority(command))