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

Customize tokio runtime for sync operations? #72

Open
kylebarron opened this issue Nov 1, 2024 · 0 comments
Open

Customize tokio runtime for sync operations? #72

kylebarron opened this issue Nov 1, 2024 · 0 comments

Comments

@kylebarron
Copy link
Member

Right now we use a hard-coded, global multi-threaded tokio runtime:

static RUNTIME: GILOnceCell<Arc<Runtime>> = GILOnceCell::new();
/// Get the tokio runtime for sync requests
pub(crate) fn get_runtime(py: Python<'_>) -> PyResult<Arc<Runtime>> {
let runtime = RUNTIME.get_or_try_init(py, || {
Ok::<_, PyErr>(Arc::new(Runtime::new().map_err(|err| {
PyValueError::new_err(format!("Could not create tokio runtime. {}", err))
})?))
})?;
Ok(runtime.clone())
}

Perhaps we should let users customize the parameters of that runtime, and pass in the runtime as a kwarg?

I figure this probably doesn't really matter because the sync operations mean only one will really happen at once?

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

No branches or pull requests

1 participant