Skip to content
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

Integration with Asyncio #32

Closed
thiagokokada opened this issue Aug 22, 2019 · 1 comment
Closed

Integration with Asyncio #32

thiagokokada opened this issue Aug 22, 2019 · 1 comment

Comments

@thiagokokada
Copy link

First, thanks! This is a great library. I am writing a asyncio based library and I am integrating pulsectl on it.

For now I just started a thread and let pulsectl run on it, however it would be interesting to have proper asyncio integration with pulsectl with it. I saw the other issue with gobject (#11) and I am interested if you know some tips on how to integrate pulsectl with async.

@mk-fg
Copy link
Owner

mk-fg commented Aug 22, 2019

Hi,

There's also https://github.com/mk-fg/python-pulse-control#event-handling-code-threads section in the README about such eventloop integration.
Specifically, I think you'd want to use set_poll_func wrapper, which libpulse exposes for that.
Don't think it should break high-level wrappers if you're willing to treat libpulse calls as instant/blocking ones, but as also mentioned there, didn't really look into such integration myself beyond what mentioned in #11 already.

Ideally for asyncio there'd have to be an entirely separate module - e.g. aiopulsectl - which would have all its calls async (which they are, especially if you're accessing pulse over crappy network), but that'd be an entirely different code with different api.
It should be relatively straightforward to implement on top of same ctypes wrappers (with asyncio poller callback set), especially if you only need like 5 calls from there, so I'd probably do that instead of trying to shoehorn this module into asyncio project in a blocking fashion.

If you'll end up going the second way (a proper asyncio libpulse wrapper), I'd suggest posting it to github/pypi, even if it'll end up having just a few calls that you need wrapped - that's how this one started too, and turned out to be useful to people somehow anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants