File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 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 (
3838 PyBytes_AsStringAndSize,
3939 Py_SIZE, PyBytes_AS_STRING, PyBUF_WRITABLE
4040)
41+ from cpython.pycapsule cimport PyCapsule_New
4142
4243from . import _noop
4344
@@ -3108,6 +3109,13 @@ cdef class Loop:
31083109' asyncgen' : agen
31093110 })
31103111
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+
31113119
31123120cdef void __loop_alloc_buffer(uv.uv_handle_t* uvhandle,
31133121 size_t suggested_size,
You can’t perform that action at this time.
0 commit comments