use std::future::Future;
use crate::{
coroutine::{cancel::ThrowCallback, Coroutine},
instance::Bound,
types::PyString,
Py, PyAny, PyResult, Python,
};
pub fn new_coroutine<'py, F>(
name: &Bound<'py, PyString>,
qualname_prefix: Option<&'static str>,
throw_callback: Option<ThrowCallback>,
future: F,
) -> Coroutine
where
F: Future<Output = PyResult<Py<PyAny>>> + Send + 'static,
{
Coroutine::new(Some(name.clone()), qualname_prefix, throw_callback, future)
}
pub struct AssumeAttachedInCoroutine(());
impl AssumeAttachedInCoroutine {
pub unsafe fn new() -> Self {
Self(())
}
pub fn py(&self) -> Python<'_> {
unsafe { Python::assume_attached() }
}
}