Skip to content

Commit cad49b1

Browse files
committed
Add non-blocking read methods for async I/O
- read_nonblock(size=-1): Read available bytes immediately, never blocks - readable_amount(): Return bytes available without blocking - at_eof(): Check if at EOF with no more data These methods enable async I/O patterns where Python code needs to check for available data without blocking, suitable for asyncio integration. Tests demonstrate Erlang streaming data while Python reads asynchronously.
1 parent ea1de38 commit cad49b1

5 files changed

Lines changed: 1306 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
- `py_buffer:close/1` - Signal EOF, wake all readers
1111
- Python `PyBuffer` type with file-like interface:
1212
- `read(size)`, `readline()`, `readlines()` - Blocking reads with GIL released
13+
- `read_nonblock(size)` - Non-blocking read for async I/O
14+
- `readable_amount()` - Bytes available without blocking
15+
- `at_eof()` - Check if at EOF with no more data
1316
- `seek(offset, whence)`, `tell()` - Position tracking
1417
- `find(sub)` - Fast substring search via memmem/memchr
1518
- `memoryview(buf)` - Zero-copy buffer protocol

0 commit comments

Comments
 (0)