Skip to content

Commit

Permalink
queue: removed noexcept for io_uring_peek_batch_cqe for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
YoSTEALTH committed Jun 5, 2024
1 parent f530918 commit 1d5a2b5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/liburing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dynamic_import import importer


__version__ = '2024.6.1'
__version__ = '2024.6.4'


importer(exclude_dir=['lib', 'include'])
Expand Down
2 changes: 1 addition & 1 deletion src/liburing/queue.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/liburing/queue.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions test/queue/get_cqe_test.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 1d5a2b5

Please sign in to comment.