nvflare.fuel.utils.pipe.memory_pipe module

class MemoryPipe(token: str, mode: Mode = Mode.ACTIVE)[source]

Bases: Pipe

Creates the pipe.

Parameters:

mode (Mode) – Mode of the endpoint. A pipe has two endpoints. An endpoint can be either the one that initiates communication or the one listening.

LOCK = <unlocked _thread.lock object>
PIPE_PAIRS = {}
can_resend() bool[source]

Whether the pipe is able to resend a message.

clear()[source]

Clear the pipe

close()[source]

Close the pipe

Returns: None

open(name: str)[source]

Open the pipe

Parameters:

name – name of the pipe

receive(timeout=None) Message | None[source]

Try to receive message from peer.

Parameters:

timeout – how long (number of seconds) to try If not specified, return right away.

Returns:

the message received; or None if no message

send(msg: Message, timeout=None) bool[source]

Sends the specified message to the peer.

Parameters:
  • msg – the message to be sent

  • timeout – if specified, number of secs to wait for the peer to read the message. If not specified, wait indefinitely.

Returns:

Whether the message is read by the peer.