Skip to content

Commit 57d7fba

Browse files
committed
Add getter functionto access the ready queue
1 parent 7783f1c commit 57d7fba

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

tests/test_base.py

+6
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,12 @@ def test_loop_call_later_handle_when_after_fired(self):
873873
self.loop.run_until_complete(fut)
874874
self.assertEqual(handle.when(), when)
875875

876+
def test_get_ready_queue(self):
877+
l1 = len(self.loop.get_ready_queue())
878+
self.loop.call_soon(lambda: None)
879+
l2 = len(self.loop.get_ready_queue())
880+
self.assertEqual(l1, l2-1)
881+
876882

877883
class TestBaseAIO(_TestBase, AIOTestCase):
878884
pass

uvloop/loop.pyi

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ from typing import (
77
Any,
88
Awaitable,
99
Callable,
10+
Deque,
1011
Dict,
1112
Generator,
1213
List,
@@ -292,3 +293,4 @@ class Loop:
292293
*,
293294
fallback: bool = ...
294295
) -> int: ...
296+
def get_ready_queue(self) -> Deque[asyncio.Handle]: ...

uvloop/loop.pyx

+3
Original file line numberDiff line numberDiff line change
@@ -3220,6 +3220,9 @@ cdef class Loop:
32203220
except Exception as ex:
32213221
self.call_soon_threadsafe(future.set_exception, ex)
32223222

3223+
# Allow external access to the ready queue for advanced scheduling and introspection
3224+
def get_ready_queue(self):
3225+
return self._ready
32233226

32243227
# Expose pointer for integration with other C-extensions
32253228
def libuv_get_loop_t_ptr(loop):

0 commit comments

Comments
 (0)