Channel#
- class maize.core.channels.Channel[source]#
-
Represents a communication channel that will be plugged into a Port.
- __init__()#
Methods
__init__
()close
()Closes the channel.
flush
([timeout])Flush the contents of the channel.
kill
()Kills the channel, called at network shutdown and ensures no orphaned processes.
receive
([timeout])Receive an item.
send
(item[, timeout])Send an item.
Attributes
Returns whether the channel is active.
Returns whether the channel is ready to receive from.
Returns the current approximate size of the buffer
- abstract flush(timeout: float = 0.1) list[T] [source]#
Flush the contents of the channel.
- Parameters:
timeout – The timeout for item retrieval
- Returns:
List of unserialized channel contents
- Return type:
list[T]
- abstract kill() None [source]#
Kills the channel, called at network shutdown and ensures no orphaned processes.
- abstract receive(timeout: float | None = None) T | None [source]#
Receive an item.
- Parameters:
timeout – Timeout in seconds to wait for an item
- Returns:
The received item, or
None
if the channel is empty- Return type:
T | None
- abstract send(item: T, timeout: float | None = None) None [source]#
Send an item.
Will attempt to send an item of any type into a channel, potentially blocking if the channel is full.
- Parameters:
item – Item to send
timeout – Timeout in seconds to wait for space in the channel
- Raises:
ChannelFull – If the channel is already full