awestlake87 / pyo3-asyncio

Other
312 stars 48 forks source link

Using PyO3 with trio #66

Open thedrow opened 2 years ago

thedrow commented 2 years ago

Has this library been tested with trio-asyncio? Is there a way we could come up with a native trio integration?

awestlake87 commented 2 years ago

Sorry for the delay on this, I've had a busy week!

I haven't tested it with Trio personally, but it seems like supporting it would be similar to supporting uvloop.

It seems like trio may be a more invasive library than uvloop when it comes to integrating with asyncio, so it might involve a bit more boilerplate to work around, but using something like aio_as_trio might allow pyo3-asyncio's conversions to work fairly seamlessly. At the end of the day, pyo3-asyncio is just calling the asyncio Python functions, so if trio adds a compatibility layer to make those calls work, I don't see why it wouldn't work for this library.

If you try it out, let me know how it goes! It might be worth adding some examples or features to make it easier to work with!