20
pyo3 async runtime (lemmy.physfluids.fr)

Hello,

I am trying to wrap some Rust code that uses sea-orm compiled with "runtime-tokio-rustls" feature. I am using the new pyo3 "experimental-async" feature, which AFAIK is based on pyo3_async.

So I get that this is supposed to be runtime-agnostic, and not have two event loops, one for python async and one for rust async.

But, how do I tell pyo3 to use tokio runtime specifically? Or, how do I set up Python asyncio eventloop to use tokio somehow?

Indeed, it seems that it does not use tokio runtime, so I get this error when I invoke the rust async function from Python:

pyo3_runtime.PanicException: this functionality requires a Tokio context
you are viewing a single comment's thread
view the rest of the comments
[-] Giooschi@lemmy.world 3 points 7 months ago* (last edited 7 months ago)

If your goal is to just .await some future that require the Tokio runtime you can use the async-compat crate.

this post was submitted on 08 Apr 2024
20 points (100.0% liked)

Rust

5938 readers
1 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS