python/cpython · error · RuntimeError
get_buffer() returned an empty buffer
Error message
get_buffer() returned an empty buffer
What it means
Error "get_buffer() returned an empty buffer" thrown in python/cpython.
Source
Thrown at Lib/asyncio/protocols.py:207
def pipe_connection_lost(self, fd, exc):
"""Called when a file descriptor associated with the child process is
closed.
fd is the int file descriptor that was closed.
"""
def process_exited(self):
"""Called when subprocess has exited."""
def _feed_data_to_buffered_proto(proto, data):
data_len = len(data)
start = 0
while data_len:
buf = proto.get_buffer(data_len)
buf_len = len(buf)
if not buf_len:
raise RuntimeError('get_buffer() returned an empty buffer')
if buf_len >= data_len:
buf[:data_len] = data[start:] if start else data
proto.buffer_updated(data_len)
return
else:
buf[:buf_len] = data[start:start + buf_len]
proto.buffer_updated(buf_len)
start += buf_len
data_len -= buf_len
View on GitHub (pinned to bc6749cc3b)
Solutions
- Implement get_buffer() in your protocol's buffer protocol to return a non-empty buffer, or return -1 to indicate no buffer is available.
- Ensure the buffer object remains alive for the duration of the write.
When it happens
Trigger: Raised in BufferedProtocol when get_buffer() returns an empty buffer.
Common situations: See trigger scenarios.
AI-assisted analysis of python/cpython@bc6749cc3b (2026-08-14).
Data as JSON: /api/errors/5bdd9d836b8ecb5c.
Report an issue: GitHub.