Skip to content

How to share libuv between multiple libraries #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iceboy233 opened this issue Sep 2, 2016 · 9 comments
Closed

How to share libuv between multiple libraries #52

iceboy233 opened this issue Sep 2, 2016 · 9 comments
Labels

Comments

@iceboy233
Copy link

If there are other C libraries using libuv and expose python interface, is there a way to use the same uv event loop for uvloop and the library?

@asvetlov
Copy link
Contributor

asvetlov commented Sep 3, 2016

To achieve it uvloop should only expose uv_loop_t instance, isn't it?

@1st1
Copy link
Member

1st1 commented Sep 3, 2016

What's the use case?

@1st1 1st1 added the question label Sep 3, 2016
@iceboy233
Copy link
Author

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
Copy link
Member

1st1 commented 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
Copy link
Member

1st1 commented Oct 21, 2016

@iceb0y Are you still working on this? I could probably expose a semi-public ctypes Ptr to the libuv event loop.

@rhizoome
Copy link

Well, I'll need that too, I am writing a portable messaging library chirp connecting the major platforms (python, node, ruby... etc and C of course). The most efficient way to write bindings is uvloop and chirp sharing uv_loop_t. It shouldn't be too difficult to grab the pointer somewhere. It will take some time till I am writing the bindings... if there is no API for this till then, I'l do the PR.

@MarkReedZ
Copy link

MarkReedZ commented 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
Copy link

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
Copy link
Member

fantix commented Sep 9, 2022

Fixed in #310

@fantix fantix closed this as completed Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants