pychanio supports multiple channel types to model safe communication across coroutines. In this chapter, we'll explore the available channel interfaces and learn how to control access using the split() function.
Channel Types
At the core, all channels in pychanio are full-duplex (send + receive). But you can split them into directional views for better safety and intent clarity:
1. Full-Duplex Channel
Created using:
ch =chan()
You can both send and receive from this channel.
ch << value # sendawait (ch >>None) # receive
2. Send-Only Channel
Created via:
send_only, _ =split(ch)
You can only send on this channel.
send_only << value
Attempting to receive from a send-only channel will raise an error.
3. Receive-Only Channel
Created via:
You can only receive from this channel.
Sending to a receive-only channel is not permitted.