You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm playing with a HTTP server called h2o which supports to be used as a library and I'm trying to make a python binding for it (just for fun now - if it could be done, we can get a super high performance HTTP server). The server supports its own event loop and also uv loop. It'll be nice if we could make python bindings of these kind of libraries which share a single event loop.
I have a server that sets up uvloop in python then runs in C. To access the loop I call out to python. It would be nice to have access to the uv_loop_t to attach say this redis C client to the loop using the following code.
Exposing the loop may not be a good idea as I believe I see uvloop and other libraries using the loop's data field. It would at least need a note. Locally I've exposed the loop by adding a function that returns it as a PyLong and am using it.
Activity
asvetlov commentedon Sep 3, 2016
To achieve it uvloop should only expose
uv_loop_tinstance, isn't it?1st1 commentedon Sep 3, 2016
What's the use case?
iceboy233 commentedon Sep 4, 2016
I'm playing with a HTTP server called h2o which supports to be used as a library and I'm trying to make a python binding for it (just for fun now - if it could be done, we can get a super high performance HTTP server). The server supports its own event loop and also uv loop. It'll be nice if we could make python bindings of these kind of libraries which share a single event loop.
1st1 commentedon Sep 5, 2016
Interesting. Well, in theory we could provide some API for that, but somebody will have to pioneer and submit a PR with an example use case code.
1st1 commentedon Oct 21, 2016
@iceb0y Are you still working on this? I could probably expose a semi-public ctypes Ptr to the libuv event loop.
MarkReedZ commentedon Apr 11, 2018
I have a server that sets up uvloop in python then runs in C. To access the loop I call out to python. It would be nice to have access to the uv_loop_t to attach say this redis C client to the loop using the following code.
https://github.com/redis/hiredis/blob/master/adapters/libuv.h
MarkReedZ commentedon Apr 13, 2018
Exposing the loop may not be a good idea as I believe I see uvloop and other libraries using the loop's data field. It would at least need a note. Locally I've exposed the loop by adding a function that returns it as a PyLong and am using it.
fantix commentedon Sep 9, 2022
Fixed in #310