当前位置: 首页>>代码示例>>Python>>正文


Python zerorpc.Server方法代码示例

本文整理汇总了Python中zerorpc.Server方法的典型用法代码示例。如果您正苦于以下问题:Python zerorpc.Server方法的具体用法?Python zerorpc.Server怎么用?Python zerorpc.Server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zerorpc的用法示例。


在下文中一共展示了zerorpc.Server方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: logReturnVal

# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Server [as 别名]
def logReturnVal(**kwargs):
    output = ""
    for key, value in kwargs.iteritems():
        if isinstance(value, str):
            #add apostrophes for string values
            value = "\'"+value+"\'"
        elif isinstance(value, int):
            value = ''.join('%02X' % value)
        else:
            newValue = ""
            for i in value:
                if isinstance(i, int):
                    newValue += '%02X' % i
                else:
                    newValue += str(i)
            value = newValue
        output += key + ':' + value + ', '
    output = output.rstrip(', ') #remove last comma and space
    logging.info("<-- "+output+'\n')

######################
#Server configuration#
###################### 
开发者ID:kamwar,项目名称:simLAB,代码行数:25,代码来源:pyscard_rpc_ctrl.py

示例2: run

# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Server [as 别名]
def run(self):
        
        host = qkit.cfg.get("ris_host","127.0.0.1")
        port = int(qkit.cfg.get("ris_port",5700))
        socket_bound = False
        for newport in range(port,port+20):
            try:
                self.ris = zerorpc.Server(QKIT_visible())
                self.ris.bind("tcp://%s:%d"%(host,newport))
                host = qkit.cfg.get("ris_host","127.0.0.1")
                qkit.cfg["ris_host"] = host
                qkit.cfg["ris_port"] = newport
                socket_bound = True
                break
            except zmq.ZMQError as e:
                logging.debug(e)
                socket_bound = False
                self.ris.stop()
                del self.ris
        if not socket_bound:
            logging.warning("RIS: address/port in use: ZMQError. \nMaybe another 20 instances of QKIT are running?")
            logging.warning("Not starting RIS.")
            return False
        # run the thread
        self.ris.run() 
开发者ID:qkitgroup,项目名称:qkit,代码行数:27,代码来源:ri_service.py

示例3: runServer

# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Server [as 别名]
def runServer(self, endpoint):
        self.s = zerorpc.Server(self)
        #self.s.bind(endpoint)
        try:
            self.s.bind(endpoint)
        except zmq.ZMQError as e:
            if e.errno == zmq.EADDRINUSE:
                logging.info("Pyscard RPC server already running\n")
            else:
                logging.warning("Pyscard RPC server " + endpoint + " could not be started")
            self.s.close()
            sys.exit(0)

        #create result file only when server is started
        dir = os.path.dirname(__file__)
        resultFile = dir + "/../pyscard_rpc.log"
        FORMATTER = logging.Formatter(fmt='%(asctime)s %(message)s', datefmt='%H:%M:%S')
        fileHndl = logging.FileHandler(resultFile, mode='w')
        fileHndl.setFormatter(FORMATTER)
        fileHndl.setLevel(logging.DEBUG)

        logger = logging.getLogger()
        logger.addHandler(fileHndl)

        logging.info("Pyscard RPC Server " + endpoint + " started\n")

        self.s.run()
        return self 
开发者ID:kamwar,项目名称:simLAB,代码行数:30,代码来源:pyscard_rpc_ctrl.py

示例4: run

# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Server [as 别名]
def run(self):
        try:
            import zerorpc
            server = zerorpc.Server(self.restful_robot)
            server.bind('tcp://{}:{}'.format(self.host, self.port))
            server.run()
        except ImportError:
            logger.warning(("Warning: The Python module 'zerorpc' is not installed. "
                            "Therefore the feature RemoteRobotServer is disabled. "
                            "On most systems this module can be installed with the command 'pip install zerorpc'.")) 
开发者ID:poppy-project,项目名称:pypot,代码行数:12,代码来源:server.py

示例5: run_sum_server

# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Server [as 别名]
def run_sum_server():
    import zerorpc

    class SumServer(object):
        def sum(self, x, y):
            return x + y

    server = zerorpc.Server(SumServer())
    server.bind("tcp://127.0.0.1:6000")
    server.run() 
开发者ID:choleraehyq,项目名称:aiorpc,代码行数:12,代码来源:benchmark_zerorpc.py

示例6: _run_rpc

# 需要导入模块: import zerorpc [as 别名]
# 或者: from zerorpc import Server [as 别名]
def _run_rpc(self):
        logger.info("Starting RPC server (agent mode)")

        if 'PSDASH_REGISTER_TO' in self.app.config:
            self._register_agent()

        service = self.get_local_node().get_service()
        self.server = zerorpc.Server(service)
        self.server.bind('tcp://%s:%s' % (self.app.config.get('PSDASH_BIND_HOST', self.DEFAULT_BIND_HOST),
                                          self.app.config.get('PSDASH_PORT', self.DEFAULT_PORT)))
        self.server.run() 
开发者ID:Jahaja,项目名称:psdash,代码行数:13,代码来源:run.py


注:本文中的zerorpc.Server方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。