class CQE#
Completion Queue Entry (CQE)
Example
>>> entry = cqe[0] >>> entry.user_data, entry.res, entry.flags (1, 0, 0)
Setup used to run this example
'CQE', 'Cqe.res_at', 'Cqe.user_data_at', 'Cqe.user_data_res', 'io_uring_cqe_seen', 'io_uring_cqe_get_data64', 'io_uring_cqe_nr', ) # fmt: skip def done_seen(ns): '''`done`, with `cqe[0]` the first completion (user_data 1).''' io_uring_wait_cqe(done(ns), ns['cqe'])
Note
- Points into the ring's completion queue:
RuntimeErroronce the ring has exited, and the entry is only valid untilio_uring_cqe_seen/io_uring_cq_advance.
property user_data: int#
The user_data set on the request's sqe (an int): the kernel copies it into every completion of the request; a io_uring_prep_msg_ring* message carries the sender's data here.
property res: int#
The request's result: what the matching system call returns (bytes read or sent, a new file descriptor, 0), or -errno for a failure (io_uring never sets errno); a negative one raises the OSError of that errno. OSError: ECANCELED: the request was cancelled, or an earlier request of its link chain failed.
property flags: int#
The completion's IORING_CQE_F_* flags.
Flags
IORING_CQE_F_BUFFERA provided buffer was used: its id is flags >> IORING_CQE_BUFFER_SHIFT.IORING_CQE_F_MOREMore completions of this request follow (multishot, zero-copy send).IORING_CQE_F_SOCK_NONEMPTYThe socket still had data after this receive. 5.19+IORING_CQE_F_NOTIFA zero-copy send's notification: its buffer may be reused now.IORING_CQE_F_BUF_MOREThe buffer is partly used, later completions continue in it.IORING_CQE_F_SKIPA filler entry of an IORING_SETUP_CQE_MIXED ring: nothing to read.IORING_CQE_F_32A 32-byte entry of an IORING_SETUP_CQE_MIXED ring (see big_cqe).
Note
- A multishot request (accept, receive, read, poll, timeout) posts one completion per event with
IORING_CQE_F_MORE; the one without it is the last (an error, a cancel:resraisesOSError: ECANCELED, or no buffer left): re-arm it if wanted. The ring keeps the request'suser_datauntil that last one. - A zero-copy send posts its result first (with
IORING_CQE_F_MORE), then a notification withIORING_CQE_F_NOTIFand the sameuser_dataonce the kernel is done with the buffer. IORING_CQE_F_BUF_MOREonly comes from a buffer ring set up withIOU_PBUF_RING_INC: the buffer returns to you when fully used, or on an error.
property big_cqe: bytes | None#
The 16 bytes after a 32-byte completion (a copy): every completion of an IORING_SETUP_CQE32 ring, those with IORING_CQE_F_32 of an IORING_SETUP_CQE_MIXED one. What the request put there (e.g. IORING_OP_URING_CMD); None for a 16-byte completion.
Example
>>> cqe[0].big_cqe # a NOP on an `IORING_SETUP_CQE32` ring b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
Setup used to run this example
def done_cqe32(ns): io_uring_wait_cqe(done(ns, IORING_SETUP_CQE32), ns['cqe'])