本文整理汇总了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#
######################
示例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()
示例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
示例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'."))
示例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()
示例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()