File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change
1
+ from uvloop import _testbase as tb
2
+
3
+ class Test_UV_Pointers (tb .UVTestCase ):
4
+ def test_get_uvloop_ptr (self ):
5
+ self .assertGreater (self .new_loop ().get_uvloop_ptr (), 0 )
6
+
7
+ def test_get_uvloop_ptr_capsule (self ):
8
+ self .assertIsNotNone (self .new_loop ().get_uvloop_ptr_capsule ())
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ from cpython cimport (
38
38
PyBytes_AsStringAndSize,
39
39
Py_SIZE, PyBytes_AS_STRING, PyBUF_WRITABLE
40
40
)
41
+ from cpython.pycapsule cimport PyCapsule_New
41
42
42
43
from . import _noop
43
44
@@ -3108,6 +3109,13 @@ cdef class Loop:
3108
3109
' asyncgen' : agen
3109
3110
})
3110
3111
3112
+ # Expose pointer for integration with other C-extensions
3113
+ def get_uvloop_ptr (self ):
3114
+ return < uint64_t> self .uvloop
3115
+
3116
+ def get_uvloop_ptr_capsule (self ):
3117
+ return PyCapsule_New(< void * > self .uvloop, NULL , NULL )
3118
+
3111
3119
3112
3120
cdef void __loop_alloc_buffer(uv.uv_handle_t* uvhandle,
3113
3121
size_t suggested_size,
You can’t perform that action at this time.
0 commit comments