diff --git a/src/liburing/__init__.py b/src/liburing/__init__.py index 2f9eeb0..41141c4 100644 --- a/src/liburing/__init__.py +++ b/src/liburing/__init__.py @@ -1,7 +1,7 @@ from dynamic_import import importer -__version__ = '2024.6.1' +__version__ = '2024.6.4' importer(exclude_dir=['lib', 'include']) diff --git a/src/liburing/queue.pxd b/src/liburing/queue.pxd index b63b5ab..1edd847 100644 --- a/src/liburing/queue.pxd +++ b/src/liburing/queue.pxd @@ -60,7 +60,7 @@ cpdef int io_uring_ring_dontfork(io_uring ring) nogil cpdef int io_uring_queue_exit(io_uring ring) nogil cpdef unsigned int io_uring_peek_batch_cqe(io_uring ring, io_uring_cqe cqes, - unsigned int count) noexcept nogil + unsigned int count) nogil cpdef int io_uring_wait_cqes(io_uring ring, io_uring_cqe cqe_ptr, unsigned int wait_nr, diff --git a/src/liburing/queue.pyx b/src/liburing/queue.pyx index a5834b6..26a4010 100644 --- a/src/liburing/queue.pyx +++ b/src/liburing/queue.pyx @@ -277,8 +277,8 @@ cpdef int io_uring_queue_exit(io_uring ring) nogil: cpdef unsigned int io_uring_peek_batch_cqe(io_uring ring, io_uring_cqe cqes, - unsigned int count) noexcept nogil: - return __io_uring_peek_batch_cqe(&ring.ptr, &cqes.ptr, count) + unsigned int count) nogil: + return trap_error(__io_uring_peek_batch_cqe(&ring.ptr, &cqes.ptr, count)) cpdef int io_uring_wait_cqes(io_uring ring, io_uring_cqe cqe_ptr, @@ -324,8 +324,8 @@ cpdef int io_uring_buf_ring_head(io_uring ring, int buf_group, uint16_t head) no cpdef inline void io_uring_cq_advance(io_uring ring, unsigned int nr) noexcept nogil: __io_uring_cq_advance(&ring.ptr, nr) -cpdef inline void io_uring_cqe_seen(io_uring ring, io_uring_cqe nr) noexcept nogil: - __io_uring_cqe_seen(&ring.ptr, nr.ptr) +cpdef inline void io_uring_cqe_seen(io_uring ring, io_uring_cqe cqe) noexcept nogil: + __io_uring_cqe_seen(&ring.ptr, cqe.ptr) # Command prep helpers diff --git a/test/conftest.py b/test/conftest.py index 781036f..35c550f 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -38,7 +38,7 @@ def tmp_dir(): def ring(): ring = liburing.io_uring() try: - liburing.io_uring_queue_init(32, ring) + liburing.io_uring_queue_init(1024, ring) yield ring finally: liburing.io_uring_queue_exit(ring) diff --git a/test/queue/get_cqe_test.py b/test/queue/get_cqe_test.py index 13954be..59d5566 100644 --- a/test/queue/get_cqe_test.py +++ b/test/queue/get_cqe_test.py @@ -1,7 +1,7 @@ import liburing -def test_peek_batch(ring, cqe): +def test_for_each(ring, cqe): loop = 300 for i in range(loop): sqe = liburing.io_uring_get_sqe(ring) @@ -10,17 +10,18 @@ def test_peek_batch(ring, cqe): assert (counter := liburing.io_uring_submit(ring)) == loop liburing.io_uring_wait_cqe_nr(ring, cqe, counter) # wait for all to be ready - # >>> difference START - cq_ready = liburing.io_uring_peek_batch_cqe(ring, cqe, counter) - for i in range(cq_ready): + # >>> difference START + cq_ready = 0 + for index in range(liburing.io_uring_for_each_cqe(ring, cqe)): assert cqe[i].user_data == i+1 + cq_ready += 1 # <<< difference END assert cq_ready == loop liburing.io_uring_cq_advance(ring, cq_ready) # free seen entries -def test_for_each(ring, cqe): +def test_peek_batch(ring, cqe): loop = 300 for i in range(loop): sqe = liburing.io_uring_get_sqe(ring) @@ -29,11 +30,10 @@ def test_for_each(ring, cqe): assert (counter := liburing.io_uring_submit(ring)) == loop liburing.io_uring_wait_cqe_nr(ring, cqe, counter) # wait for all to be ready - # >>> difference START - cq_ready = 0 - for index in range(liburing.io_uring_for_each_cqe(ring, cqe)): + # >>> difference START + cq_ready = liburing.io_uring_peek_batch_cqe(ring, cqe, counter) + for i in range(cq_ready): assert cqe[i].user_data == i+1 - cq_ready += 1 # <<< difference END assert cq_ready == loop