Connect to RPC Server Parameters ---------- url : str The url of the host port : int The port to connect to key : str, optional Additional key to match server session_timeout : float, optional The duration of the session in seconds, allows
(
url,
port,
key="",
session_timeout=0,
session_constructor_args=None,
enable_logging=False,
)
| 479 | |
| 480 | |
| 481 | def connect( |
| 482 | url, |
| 483 | port, |
| 484 | key="", |
| 485 | session_timeout=0, |
| 486 | session_constructor_args=None, |
| 487 | enable_logging=False, |
| 488 | ): |
| 489 | """Connect to RPC Server |
| 490 | |
| 491 | Parameters |
| 492 | ---------- |
| 493 | url : str |
| 494 | The url of the host |
| 495 | |
| 496 | port : int |
| 497 | The port to connect to |
| 498 | |
| 499 | key : str, optional |
| 500 | Additional key to match server |
| 501 | |
| 502 | session_timeout : float, optional |
| 503 | The duration of the session in seconds, allows server to kill |
| 504 | the connection when duration is longer than this value. |
| 505 | When duration is zero, it means the request must always be kept alive. |
| 506 | |
| 507 | session_constructor_args: List |
| 508 | List of additional arguments to passed as the remote session constructor. |
| 509 | The first element of the list is always a string specifying the name of |
| 510 | the session constructor, the following args are the positional args to that function. |
| 511 | |
| 512 | enable_logging: boolean |
| 513 | flag to enable/disable logging. Logging is disabled by default. |
| 514 | |
| 515 | Returns |
| 516 | ------- |
| 517 | sess : RPCSession |
| 518 | The connected session. |
| 519 | |
| 520 | Examples |
| 521 | -------- |
| 522 | Normal usage |
| 523 | .. code-block:: python |
| 524 | |
| 525 | client = rpc.connect(server_url, server_port, server_key) |
| 526 | |
| 527 | Session_constructor can be used to customize the session in the remote |
| 528 | The following code connects to a remote internal server via a proxy |
| 529 | by constructing another RPCClientSession on the proxy machine and use that |
| 530 | as the serving session of the proxy endpoint. |
| 531 | |
| 532 | .. code-block:: python |
| 533 | |
| 534 | client_via_proxy = rpc.connect( |
| 535 | proxy_server_url, proxy_server_port, proxy_server_key, enable_logging |
| 536 | session_constructor_args=[ |
| 537 | "rpc.Connect", internal_url, internal_port, internal_key, internal_logging]) |
| 538 |
no test coverage detected
searching dependent graphs…