forked from M-Labs/artiq
1
0
Fork 0

protocols/pc_rpc: add get_local_host to clients

This commit is contained in:
Sebastien Bourdeauducq 2016-04-04 19:07:08 +08:00
parent ce30045dd4
commit 69516136c4
1 changed files with 14 additions and 0 deletions

View File

@ -132,6 +132,10 @@ class Client:
identification information of the server.""" identification information of the server."""
return (self.__target_names, self.__description) return (self.__target_names, self.__description)
def get_local_host(self):
"""Returns the address of the local end of the connection."""
return self.__socket.getsockname()[0]
def close_rpc(self): def close_rpc(self):
"""Closes the connection to the RPC server. """Closes the connection to the RPC server.
@ -224,6 +228,10 @@ class AsyncioClient:
selected yet.""" selected yet."""
return self.__selected_target return self.__selected_target
def get_local_host(self):
"""Returns the address of the local end of the connection."""
return self.__writer.get_extra_info("socket").getsockname()[0]
def get_rpc_id(self): def get_rpc_id(self):
"""Returns a tuple (target_names, description) containing the """Returns a tuple (target_names, description) containing the
identification information of the server.""" identification information of the server."""
@ -396,6 +404,12 @@ class BestEffortClient:
return self.__do_rpc(name, args, kwargs) return self.__do_rpc(name, args, kwargs)
return proxy return proxy
def get_selected_target(self):
raise NotImplementedError
def get_local_host(self):
raise NotImplementedError
def _format_arguments(arguments): def _format_arguments(arguments):
fmtargs = [] fmtargs = []