本文整理匯總了Python中rpyc.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python rpyc.connect方法的具體用法?Python rpyc.connect怎麽用?Python rpyc.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rpyc
的用法示例。
在下文中一共展示了rpyc.connect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ensure_connected
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def ensure_connected(func):
@wraps(func)
def func_wrapper(*args):
self = args[0]
if not isinstance(self.conn, Connection) or self.conn.closed:
self.connect()
print('running {0}()'.format(func.__name__))
# 如果和rpyc服務端斷開了,則自動重新連接
try:
return func(*args)
except Exception as e:
if isinstance(e, EOFError):
self.connect()
return func(*args)
else:
raise e
return func_wrapper
示例2: service01
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def service01():
conn = rpyc.connect(host='localhost', port=18861)
root = conn.root # MyService object
# object
print root
print root.get_service_name()
print root.get_service_aliases()
# custom method
print root.get_answer() # 66
print root.exposed_get_answer() # 66
# print root.get_question() # AttributeError: cannot access 'get_question'
registrar = UDPRegistryClient()
list_of_servers = registrar.discover("foo")
print rpyc.discover(service_name='MY', host='localhost')
示例3: opt4
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def opt4(self, p_iJoy = None, p_iLine = None):
p_lLines = {}
if p_iJoy == None:
return self.opt4_datas()
if p_iJoy & CRT_LEFT or p_iJoy & CRT_RIGHT:
list = self.m_lLines[p_iLine]['options']
value = self.m_lLines[p_iLine]['value']
new = explore_list(p_iJoy, value, list)
if new:
new = int(new.replace("%", ''))
try:
try: self.con.root
except: self.con = rpyc.connect('localhost', 18861)
vol = self.con.root.change_vol(new)
if vol == new:
self.m_lLines[p_iLine]['value'] = str(new) + "%"
except:
pass
示例4: getNewtasks
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def getNewtasks(self,num):
data=[]
if self.__client is None:
self.connect()
result = self.__client.root.client_getNewtasks(num)
for task in result:
Settings.WAT_MSG_INFO['taskid']=task[0]
Settings.WAT_MSG_INFO['website']=task[1]
Settings.WAT_MSG_INFO['profile']=task[2]
msg = json.dumps(Settings.WAT_MSG_INFO)
content={"taskid":task[0],"msg":msg}
data.append(content)
return data
示例5: connect
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def connect(self):
self.disconnect()
client_config={
"allow_all_attrs": True
}
self.conn = rpyc.connect(self.host, self.port, config=client_config)
示例6: main
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def main():
username, password = login()
if username is not None:
try:
service = rpyc.connect(HOST, PORT)
manager = service.root
sessionId, name = manager.login(username, password)
print("Welcome, {}, to Meter RPYC".format(name))
interact(manager, sessionId)
except ConnectionError as err:
print("Error: Is the meter server running? {}".format(err))
示例7: conn
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def conn(cls):
connections = rpyc.connect('localhost', 15111)
connections.root.save_data(123)
print connections.root.get_data()
示例8: __init__
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def __init__(self, host, port):
c = rpyc.connect(host, port)
c._config['sync_request_timeout'] = None
self.proxy = c.root
示例9: connect
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def connect(self, service = VoidService, config = {}):
"""Same as :func:`connect <rpyc.utils.factory.connect>`, but with the ``host`` and ``port``
parameters fixed"""
if self.local_port is None:
# ParamikoMachine
stream = SocketStream(self.remote_machine.connect_sock(self.remote_port))
return rpyc.connect_stream(stream, service = service, config = config)
else:
return rpyc.connect("localhost", self.local_port, service = service, config = config)
示例10: classic_connect
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def classic_connect(self):
"""Same as :func:`classic.connect <rpyc.utils.classic.connect>`, but with the ``host`` and
``port`` parameters fixed"""
if self.local_port is None:
# ParamikoMachine
stream = SocketStream(self.remote_machine.connect_sock(self.remote_port))
return rpyc.classic.connect_stream(stream)
else:
return rpyc.classic.connect("localhost", self.local_port)
示例11: connect_all
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def connect_all(self, service = VoidService, config = {}):
"""connects to all deployed servers; returns a list of connections (order guaranteed)"""
return [s.connect(service, config) for s in self.servers]
示例12: connect
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def connect(self):
try:
self.__client = rpyc.connect(Settings.RPYC_HOST,Settings.RPYC_PORT)
self.__client.root.open()
except Exception,e:
self.close()
示例13: _init
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def _init(self):
self._taskid =int(cfg.getData('taskid'))
self._website =cfg.getData("target").get_host()
self._host =cfg.getData('RPC_SERVER_IP')
self._port =int(cfg.getData('RPC_SERVER_PORT'))
try:
self._client=rpyc.connect(self._host,self._port)
self._client.root.open()
except Exception,e:
log.error(str(e))
示例14: setup_remote_connection
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def setup_remote_connection(self):
'''
Setup rpyc server connection.
'''
self.c = rpyc.connect(self.data.localhost.ip,self.data.localhost.port)
print('Connection established to %s via port %s.'%(str(self.data.localhost.ip),str(self.data.localhost.port)))
示例15: _setup_signal_slots
# 需要導入模塊: import rpyc [as 別名]
# 或者: from rpyc import connect [as 別名]
def _setup_signal_slots(self):
self.cb_scale.currentIndexChanged.connect(self._range_changed) #combo box