proxystore_ex.connectors.dim.zmq¶
ZeroMQ-based distributed in-memory connector implementation.
ZeroMQConnector
¶
ZeroMQConnector(
port: int,
address: str | None = None,
interface: str | None = None,
chunk_length: int | None = None,
timeout: float = 1,
)
ZeroMQ-based distributed in-memory connector.
Note
The first instance of this connector created on a process will
spawn a ZeroMQServer
that will store data. Hence, this connector just acts as an interface
to that server.
Parameters:
-
address
(str | None
, default:None
) –The network IP address to use. Takes precedence over
interface
if both are provided. -
interface
(str | None
, default:None
) –The network interface to use.
address
arg takes precedence if both are provided. -
port
(int
) –The desired port for the spawned server.
-
chunk_length
(int | None
, default:None
) –Message chunk size in bytes. Defaults to
MAX_CHUNK_LENGTH_DEFAULT
. -
timeout
(float
, default:1
) –Timeout in seconds to try connecting to local server before spawning one.
Raises:
-
ServerTimeoutError
–If a local server cannot be connected to within
timeout
seconds, and a new local server does not response withintimeout
seconds after being started.
Source code in proxystore_ex/connectors/dim/zmq.py
close
¶
close(kill_server: bool = True) -> None
Close the connector.
Parameters:
-
kill_server
(bool
, default:True
) –Whether to kill the server process. If this instance did not spawn the local node's server process, this is a no-op.
Source code in proxystore_ex/connectors/dim/zmq.py
config
¶
Get the connector configuration.
The configuration contains all the information needed to reconstruct the connector object.
Source code in proxystore_ex/connectors/dim/zmq.py
from_config
classmethod
¶
from_config(config: dict[str, Any]) -> ZeroMQConnector
Create a new connector instance from a configuration.
Parameters:
Source code in proxystore_ex/connectors/dim/zmq.py
evict
¶
evict(key: DIMKey) -> None
Evict the object associated with the key.
Parameters:
-
key
(DIMKey
) –Key associated with object to evict.
exists
¶
Check if an object associated with the key exists.
Parameters:
-
key
(DIMKey
) –Key potentially associated with stored object.
Returns:
-
bool
–If an object associated with the key exists.
Source code in proxystore_ex/connectors/dim/zmq.py
get
¶
Get the serialized object associated with the key.
Parameters:
-
key
(DIMKey
) –Key associated with the object to retrieve.
Returns:
-
bytes | None
–Serialized object or
None
if the object does not exist.
Source code in proxystore_ex/connectors/dim/zmq.py
get_batch
¶
Get a batch of serialized objects associated with the keys.
Parameters:
Returns:
-
list[bytes | None]
–List with same order as
keys
with the serialized objects orNone
if the corresponding key does not have an associated object.
Source code in proxystore_ex/connectors/dim/zmq.py
put
¶
Put a serialized object in the store.
Parameters:
-
obj
(bytes
) –Serialized object to put in the store.
Returns:
-
DIMKey
–Key which can be used to retrieve the object.
Source code in proxystore_ex/connectors/dim/zmq.py
put_batch
¶
Put a batch of serialized objects in the store.
Parameters:
Returns:
Source code in proxystore_ex/connectors/dim/zmq.py
ZeroMQServer
¶
ZeroMQServer implementation.
Source code in proxystore_ex/connectors/dim/zmq.py
evict
¶
evict(key: str) -> None
Evict the object associated with the key.
Parameters:
-
key
(str
) –Key associated with object to evict.
exists
¶
get
¶
put
¶
Put data in the store.
Parameters:
handle_rpc
¶
handle_rpc(rpc: RPC) -> RPCResponse
Process an RPC request.
Parameters:
-
rpc
(RPC
) –Client RPC to process.
Returns:
-
RPCResponse
–Response containing result or an exception if the operation failed.
Source code in proxystore_ex/connectors/dim/zmq.py
run_server
async
¶
Listen and reply to RPCs from clients.
Warning
This function does not return until SIGINT or SIGTERM is received.
Parameters:
-
address
(str
) –IP address the server should bind to.
-
port
(int
) –Port the server should listen on.
-
chunk_length
(int | None
, default:None
) –Message chunk size in bytes. Defaults to
MAX_CHUNK_LENGTH_DEFAULT
.
Source code in proxystore_ex/connectors/dim/zmq.py
start_server
¶
Run a local server.
Note
This function creates an event loop and executes
run_server()
within
that loop.
Parameters:
-
address
(str
) –IP address the server should bind to.
-
port
(int
) –Port the server should listen on.
-
chunk_length
(int | None
, default:None
) –Message chunk size in bytes. Defaults to
MAX_CHUNK_LENGTH_DEFAULT
.
Source code in proxystore_ex/connectors/dim/zmq.py
spawn_server
¶
spawn_server(
address: str,
port: int,
*,
chunk_length: int | None = None,
spawn_timeout: float = 5.0,
kill_timeout: float | None = 1.0
) -> Process
Spawn a local server running in a separate process.
Note
An atexit
callback is registered which will terminate the spawned
server process when the calling process exits.
Parameters:
-
address
(str
) –IP address the server should bind to.
-
port
(int
) –Port the server will listen on.
-
chunk_length
(int | None
, default:None
) –Message chunk size in bytes. Defaults to
MAX_CHUNK_LENGTH_DEFAULT
. -
spawn_timeout
(float
, default:5.0
) –Max time in seconds to wait for the server to start.
-
kill_timeout
(float | None
, default:1.0
) –Max time in seconds to wait for the server to shutdown on exit.
Returns:
-
Process
–The process that the server is running in.
Source code in proxystore_ex/connectors/dim/zmq.py
wait_for_server
¶
Wait until the server responds.
Parameters:
-
address
(str
) –Host of the server to ping.
-
port
(int
) –Port of the server to ping.
-
timeout
(float
, default:0.1
) –Max time in seconds to wait for server response.
Raises:
-
ServerTimeoutError
–If the server does not respond within the timeout.