pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/MagicStack/uvloop/commit/b332eb85e4613c29c58d89d7cae8f953701ff66b

ets/repository-6534fbc3f5e83ac0.css" /> Expose uv_loop_t pointer for integration with other C-extensions (#310) · MagicStack/uvloop@b332eb8 · GitHub
Skip to content

Commit b332eb8

Browse files
pranavtbhatfantix
andauthored
Expose uv_loop_t pointer for integration with other C-extensions (#310)
Co-authored-by: Fantix King <[email protected]>
1 parent a130375 commit b332eb8

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'pycodestyle~=2.7.0',
3535
'pyOpenSSL~=19.0.0',
3636
'mypy>=0.800',
37+
CYTHON_DEPENDENCY,
3738
]
3839

3940
# Dependencies required to build documentation.

tests/cython_helper.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from cpython.pycapsule cimport PyCapsule_GetPointer
2+
3+
4+
def capsule_equals(cap1, cap2):
5+
return PyCapsule_GetPointer(cap1, NULL) == PyCapsule_GetPointer(cap2, NULL)

tests/test_pointers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from uvloop import _testbase as tb
2+
3+
4+
class Test_UV_Pointers(tb.UVTestCase):
5+
def test_get_uv_loop_t_ptr(self):
6+
loop = self.new_loop()
7+
cap1 = loop.get_uv_loop_t_ptr()
8+
cap2 = loop.get_uv_loop_t_ptr()
9+
cap3 = self.new_loop().get_uv_loop_t_ptr()
10+
11+
import pyximport
12+
13+
pyximport.install()
14+
15+
from tests import cython_helper
16+
17+
self.assertTrue(cython_helper.capsule_equals(cap1, cap2))
18+
self.assertFalse(cython_helper.capsule_equals(cap1, cap3))

uvloop/loop.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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

4243
from . import _noop
4344

@@ -3180,6 +3181,10 @@ cdef class Loop:
31803181
except Exception as ex:
31813182
self.call_soon_threadsafe(future.set_exception, ex)
31823183

3184+
# Expose pointer for integration with other C-extensions
3185+
def get_uv_loop_t_ptr(self):
3186+
return PyCapsule_New(<void *>self.uvloop, NULL, NULL)
3187+
31833188

31843189
cdef void __loop_alloc_buffer(uv.uv_handle_t* uvhandle,
31853190
size_t suggested_size,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy