micropython/streampair: Package to create bi-directional linked stream objects.#907
micropython/streampair: Package to create bi-directional linked stream objects.#907andrewleech wants to merge 2 commits intomicropython:masterfrom
Conversation
…m objects. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
|
The RingIO module has been merged in micropython so this should be updated to use it |
a5c91c4 to
cc3ae52
Compare
|
Updated this PR with the following changes: API Updates:
New Tests:
Technical Detail: The existing ioctl implementation already correctly returns Since These tests serve as documentation that pure Python stream objects don't require C-level integration to work with micropython's polling and async infrastructure - they just need to implement the ioctl protocol correctly. |
- Replace deprecated ringbuffer with RingIO name. - Remove unused collections.deque import. - Add test_select_poll_compatibility() to verify select.poll(). - Add test_streamreader_direct_usage() for asyncio.StreamReader. The existing ioctl implementation correctly returns -1 for unsupported operations, enabling select.poll() to work with pure Python stream objects. Since asyncio.StreamReader is built on select.poll(), StreamPair works seamlessly with async I/O. These tests document that Python objects with proper ioctl() implementation work with micropython polling and async infrastructure without requiring C-level integration. Signed-off-by: Andrew Leech <andrew@alelec.net> Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
cc3ae52 to
35c671f
Compare
Returns two bi-directional linked stream objects where writes to one can be read from the other and vice/versa.
This can be used somewhat similarly to a socket.socketpair in python, like a pipe of data that can be used to connect stream consumers (eg. asyncio.StreamWriter, mock Uart)