port module

class port.Port(name=None, use_mpi=False)[source]

Bases: object

Provides a method of communication between modules.

The Port class provides an interface for creating ports and connecting them to other ports for the purpose of data transfer. Data exchange takes place by send and/or receive calls on a given port. The concept of a port is that of a data transfer “interaction.” This can be one- or two-way with sends and receives. A port is connected to only one other port; as two ends of a pipe are connected.

__eq__(other)[source]

Check for port equality

__init__(name=None, use_mpi=False)[source]

Constructs a Port object

Parameters
  • name (str) – The name of the Port object

  • use_mpi (bool) – True for MPI, False for Multiprocessing

id
Type

int

name
Type

string

use_mpi
Type

bool

__repr__()[source]

Port name representation

connect(port)[source]

Connect this port to another port

Ports must be connected for data to flow between them.

Parameters

port (Port) – A Port object to connect to

recv()[source]

Receive data from the connected port.

Warning

This function will block if no data has been sent yet.

Returns

data

Return type

any

send(data, tag=None)[source]

Send data to the connected port.

If the sending port is not connected do nothing.

Parameters
  • data (any) – This data must be pickleable

  • tag (int, optional) – MPI tag used in sending data