Skip to content

Commit e0f7ed6

Browse files
committed
rename to pyo3-async-runtimes
1 parent b12ac16 commit e0f7ed6

25 files changed

+352
-346
lines changed

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[package]
2-
name = "pyo3-asyncio-0-21"
3-
description = "PyO3 utilities for Python's Asyncio library - 0.21 fork"
2+
name = "pyo3-async-runtimes"
3+
description = "PyO3 bridges from Rust runtimes to Python's Asyncio library"
44
version = "0.21.0"
55
authors = [
66
"Andrew J Westlake <[email protected]>",
77
"David Hewitt <[email protected]>",
88
]
99
readme = "README.md"
1010
keywords = ["pyo3", "python", "ffi", "async", "asyncio"]
11-
homepage = "https://github.com/davidhewitt/pyo3-asyncio"
12-
repository = "https://github.com/davidhewitt/pyo3-asyncio"
13-
documentation = "https://docs.rs/crate/pyo3-asyncio-0-21/"
11+
homepage = "https://github.com/PyO3/pyo3-async-runtimes"
12+
repository = "https://github.com/PyO3/pyo3-async-runtimes"
13+
documentation = "https://docs.rs/crate/pyo3-async-runtimes/"
1414
categories = ["api-bindings", "development-tools::ffi"]
1515
license = "Apache-2.0"
1616
exclude = ["/.gitignore", "/codecov.yml", "/Makefile"]
@@ -22,7 +22,7 @@ members = ["pyo3-asyncio-macros"]
2222

2323
[features]
2424
async-std-runtime = ["async-std"]
25-
attributes = ["pyo3-asyncio-macros-0-21"]
25+
attributes = ["pyo3-async-runtimes-macros"]
2626
testing = ["clap", "inventory"]
2727
tokio-runtime = ["tokio"]
2828
unstable-streams = ["async-channel"]
@@ -121,7 +121,7 @@ inventory = { version = "0.3", optional = true }
121121
once_cell = "1.14"
122122
pin-project-lite = "0.2"
123123
pyo3 = "0.21"
124-
pyo3-asyncio-macros-0-21 = { path = "pyo3-asyncio-macros", version = "=0.21.0", optional = true }
124+
pyo3-async-runtimes-macros = { path = "pyo3-asyncio-macros", version = "=0.21.0", optional = true }
125125

126126
[dev-dependencies]
127127
pyo3 = { version = "0.21", features = ["macros"] }

README.md

Lines changed: 46 additions & 46 deletions
Large diffs are not rendered by default.

examples/async_std.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
use pyo3::prelude::*;
22

3-
#[pyo3_asyncio_0_21::async_std::main]
3+
#[pyo3_async_runtimes::async_std::main]
44
async fn main() -> PyResult<()> {
55
let fut = Python::with_gil(|py| {
66
let asyncio = py.import_bound("asyncio")?;
77

88
// convert asyncio.sleep into a Rust Future
9-
pyo3_asyncio_0_21::async_std::into_future(asyncio.call_method1("sleep", (1.into_py(py),))?)
9+
pyo3_async_runtimes::async_std::into_future(
10+
asyncio.call_method1("sleep", (1.into_py(py),))?,
11+
)
1012
})?;
1113

1214
println!("sleeping for 1s");

examples/tokio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use pyo3::prelude::*;
22

3-
#[pyo3_asyncio_0_21::tokio::main]
3+
#[pyo3_async_runtimes::tokio::main]
44
async fn main() -> PyResult<()> {
55
let fut = Python::with_gil(|py| {
66
let asyncio = py.import_bound("asyncio")?;
77

88
// convert asyncio.sleep into a Rust Future
9-
pyo3_asyncio_0_21::tokio::into_future(asyncio.call_method1("sleep", (1.into_py(py),))?)
9+
pyo3_async_runtimes::tokio::into_future(asyncio.call_method1("sleep", (1.into_py(py),))?)
1010
})?;
1111

1212
println!("sleeping for 1s");

examples/tokio_current_thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use pyo3::prelude::*;
22

3-
#[pyo3_asyncio_0_21::tokio::main(flavor = "current_thread")]
3+
#[pyo3_async_runtimes::tokio::main(flavor = "current_thread")]
44
async fn main() -> PyResult<()> {
55
let fut = Python::with_gil(|py| {
66
let asyncio = py.import_bound("asyncio")?;
77

88
// convert asyncio.sleep into a Rust Future
9-
pyo3_asyncio_0_21::tokio::into_future(asyncio.call_method1("sleep", (1.into_py(py),))?)
9+
pyo3_async_runtimes::tokio::into_future(asyncio.call_method1("sleep", (1.into_py(py),))?)
1010
})?;
1111

1212
println!("sleeping for 1s");

examples/tokio_multi_thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use pyo3::prelude::*;
22

3-
#[pyo3_asyncio_0_21::tokio::main(flavor = "multi_thread", worker_threads = 10)]
3+
#[pyo3_async_runtimes::tokio::main(flavor = "multi_thread", worker_threads = 10)]
44
async fn main() -> PyResult<()> {
55
let fut = Python::with_gil(|py| {
66
let asyncio = py.import_bound("asyncio")?;
77

88
// convert asyncio.sleep into a Rust Future
9-
pyo3_asyncio_0_21::tokio::into_future(asyncio.call_method1("sleep", (1.into_py(py),))?)
9+
pyo3_async_runtimes::tokio::into_future(asyncio.call_method1("sleep", (1.into_py(py),))?)
1010
})?;
1111

1212
println!("sleeping for 1s");

pyo3-asyncio-macros/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[package]
2-
name = "pyo3-asyncio-macros-0-21"
3-
description = "Proc Macro Attributes for PyO3 Asyncio - 0.21 fork"
2+
name = "pyo3-async-runtimes-macros"
3+
description = "Proc Macro Attributes for `pyo3-async-runtimes`"
44
version = "0.21.0"
55
authors = [
66
"Andrew J Westlake <[email protected]>",
77
"David Hewitt <[email protected]>",
88
]
99
readme = "../README.md"
1010
keywords = ["pyo3", "python", "ffi", "async", "asyncio"]
11-
homepage = "https://github.com/davidhewitt/pyo3-asyncio"
12-
repository = "https://github.com/davidhewitt/pyo3-asyncio"
13-
documentation = "https://docs.rs/crate/pyo3-asyncio-0-21/"
11+
homepage = "https://github.com/PyO3/pyo3-async-runtimes"
12+
repository = "https://github.com/PyO3/pyo3-async-runtimes"
13+
documentation = "https://docs.rs/crate/pyo3-async-runtimes/"
1414
categories = ["api-bindings", "development-tools::ffi"]
1515
license = "Apache-2.0"
1616
edition = "2018"

pyo3-asyncio-macros/src/lib.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use syn::spanned::Spanned;
1313
/// # Examples
1414
///
1515
/// ```ignore
16-
/// #[pyo3_asyncio_0_21::async_std::main]
16+
/// #[pyo3_async_runtimes::async_std::main]
1717
/// async fn main() -> PyResult<()> {
1818
/// Ok(())
1919
/// }
@@ -52,7 +52,7 @@ pub fn async_std_main(_attr: TokenStream, item: TokenStream) -> TokenStream {
5252
pyo3::prepare_freethreaded_python();
5353

5454
pyo3::Python::with_gil(|py| {
55-
pyo3_asyncio_0_21::async_std::run(py, main())
55+
pyo3_async_runtimes::async_std::run(py, main())
5656
.map_err(|e| {
5757
e.print_and_set_sys_last_vars(py);
5858
})
@@ -74,23 +74,23 @@ pub fn async_std_main(_attr: TokenStream, item: TokenStream) -> TokenStream {
7474
///
7575
/// Default configuration:
7676
/// ```ignore
77-
/// #[pyo3_asyncio_0_21::tokio::main]
77+
/// #[pyo3_async_runtimes::tokio::main]
7878
/// async fn main() -> PyResult<()> {
7979
/// Ok(())
8080
/// }
8181
/// ```
8282
///
8383
/// Current-thread scheduler:
8484
/// ```ignore
85-
/// #[pyo3_asyncio_0_21::tokio::main(flavor = "current_thread")]
85+
/// #[pyo3_async_runtimes::tokio::main(flavor = "current_thread")]
8686
/// async fn main() -> PyResult<()> {
8787
/// Ok(())
8888
/// }
8989
/// ```
9090
///
9191
/// Multi-thread scheduler with custom worker thread count:
9292
/// ```ignore
93-
/// #[pyo3_asyncio_0_21::tokio::main(flavor = "multi_thread", worker_threads = 10)]
93+
/// #[pyo3_async_runtimes::tokio::main(flavor = "multi_thread", worker_threads = 10)]
9494
/// async fn main() -> PyResult<()> {
9595
/// Ok(())
9696
/// }
@@ -114,21 +114,21 @@ pub fn tokio_main(args: TokenStream, item: TokenStream) -> TokenStream {
114114
/// use pyo3::prelude::*;
115115
///
116116
/// // async test function
117-
/// #[pyo3_asyncio_0_21::async_std::test]
117+
/// #[pyo3_async_runtimes::async_std::test]
118118
/// async fn test_async_sleep() -> PyResult<()> {
119119
/// async_std::task::sleep(Duration::from_secs(1)).await;
120120
/// Ok(())
121121
/// }
122122
///
123123
/// // blocking test function
124-
/// #[pyo3_asyncio_0_21::async_std::test]
124+
/// #[pyo3_async_runtimes::async_std::test]
125125
/// fn test_blocking_sleep() -> PyResult<()> {
126126
/// thread::sleep(Duration::from_secs(1));
127127
/// Ok(())
128128
/// }
129129
///
130130
/// // blocking test functions can optionally accept an event_loop parameter
131-
/// #[pyo3_asyncio_0_21::async_std::test]
131+
/// #[pyo3_async_runtimes::async_std::test]
132132
/// fn test_blocking_sleep_with_event_loop(event_loop: PyObject) -> PyResult<()> {
133133
/// thread::sleep(Duration::from_secs(1));
134134
/// Ok(())
@@ -148,16 +148,16 @@ pub fn async_std_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
148148
// Optionally pass an event_loop parameter to blocking tasks
149149
let task = if sig.inputs.is_empty() {
150150
quote! {
151-
Box::pin(pyo3_asyncio_0_21::async_std::re_exports::spawn_blocking(move || {
151+
Box::pin(pyo3_async_runtimes::async_std::re_exports::spawn_blocking(move || {
152152
#name()
153153
}))
154154
}
155155
} else {
156156
quote! {
157157
let event_loop = Python::with_gil(|py| {
158-
pyo3_asyncio_0_21::async_std::get_current_loop(py).unwrap().into()
158+
pyo3_async_runtimes::async_std::get_current_loop(py).unwrap().into()
159159
});
160-
Box::pin(pyo3_asyncio_0_21::async_std::re_exports::spawn_blocking(move || {
160+
Box::pin(pyo3_async_runtimes::async_std::re_exports::spawn_blocking(move || {
161161
#name(event_loop)
162162
}))
163163
}
@@ -187,8 +187,8 @@ pub fn async_std_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
187187
let result = quote! {
188188
#fn_impl
189189

190-
pyo3_asyncio_0_21::inventory::submit! {
191-
pyo3_asyncio_0_21::testing::Test {
190+
pyo3_async_runtimes::inventory::submit! {
191+
pyo3_async_runtimes::testing::Test {
192192
name: concat!(std::module_path!(), "::", stringify!(#name)),
193193
test_fn: &#name
194194
}
@@ -211,21 +211,21 @@ pub fn async_std_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
211211
/// use pyo3::prelude::*;
212212
///
213213
/// // async test function
214-
/// #[pyo3_asyncio_0_21::tokio::test]
214+
/// #[pyo3_async_runtimes::tokio::test]
215215
/// async fn test_async_sleep() -> PyResult<()> {
216216
/// tokio::time::sleep(Duration::from_secs(1)).await;
217217
/// Ok(())
218218
/// }
219219
///
220220
/// // blocking test function
221-
/// #[pyo3_asyncio_0_21::tokio::test]
221+
/// #[pyo3_async_runtimes::tokio::test]
222222
/// fn test_blocking_sleep() -> PyResult<()> {
223223
/// thread::sleep(Duration::from_secs(1));
224224
/// Ok(())
225225
/// }
226226
///
227227
/// // blocking test functions can optionally accept an event_loop parameter
228-
/// #[pyo3_asyncio_0_21::tokio::test]
228+
/// #[pyo3_async_runtimes::tokio::test]
229229
/// fn test_blocking_sleep_with_event_loop(event_loop: PyObject) -> PyResult<()> {
230230
/// thread::sleep(Duration::from_secs(1));
231231
/// Ok(())
@@ -246,7 +246,7 @@ pub fn tokio_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
246246
let task = if sig.inputs.is_empty() {
247247
quote! {
248248
Box::pin(async move {
249-
match pyo3_asyncio_0_21::tokio::get_runtime().spawn_blocking(move || #name()).await {
249+
match pyo3_async_runtimes::tokio::get_runtime().spawn_blocking(move || #name()).await {
250250
Ok(result) => result,
251251
Err(e) => {
252252
assert!(e.is_panic());
@@ -258,18 +258,18 @@ pub fn tokio_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
258258
} else {
259259
"unknown error".into()
260260
};
261-
Err(pyo3_asyncio_0_21::err::RustPanic::new_err(format!("rust future panicked: {}", panic_message)))
261+
Err(pyo3_async_runtimes::err::RustPanic::new_err(format!("rust future panicked: {}", panic_message)))
262262
}
263263
}
264264
})
265265
}
266266
} else {
267267
quote! {
268268
let event_loop = Python::with_gil(|py| {
269-
pyo3_asyncio_0_21::tokio::get_current_loop(py).unwrap().into()
269+
pyo3_async_runtimes::tokio::get_current_loop(py).unwrap().into()
270270
});
271271
Box::pin(async move {
272-
match pyo3_asyncio_0_21::tokio::get_runtime().spawn_blocking(move || #name(event_loop)).await {
272+
match pyo3_async_runtimes::tokio::get_runtime().spawn_blocking(move || #name(event_loop)).await {
273273
Ok(result) => result,
274274
Err(e) => {
275275
assert!(e.is_panic());
@@ -281,7 +281,7 @@ pub fn tokio_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
281281
} else {
282282
"unknown error".into()
283283
};
284-
Err(pyo3_asyncio_0_21::err::RustPanic::new_err(format!("rust future panicked: {}", panic_message)))
284+
Err(pyo3_async_runtimes::err::RustPanic::new_err(format!("rust future panicked: {}", panic_message)))
285285
}
286286
}
287287
})
@@ -312,8 +312,8 @@ pub fn tokio_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
312312
let result = quote! {
313313
#fn_impl
314314

315-
pyo3_asyncio_0_21::inventory::submit! {
316-
pyo3_asyncio_0_21::testing::Test {
315+
pyo3_async_runtimes::inventory::submit! {
316+
pyo3_async_runtimes::testing::Test {
317317
name: concat!(std::module_path!(), "::", stringify!(#name)),
318318
test_fn: &#name
319319
}

pyo3-asyncio-macros/src/tokio.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn parse_knobs(
151151
return Err(syn::Error::new_spanned(sig.fn_token, msg));
152152
}
153153

154-
let macro_name = "pyo3_asyncio_0_21::tokio::main";
154+
let macro_name = "pyo3_async_runtimes::tokio::main";
155155
let mut config = Configuration::new(is_test, rt_multi_thread);
156156

157157
for arg in args {
@@ -221,10 +221,10 @@ fn parse_knobs(
221221

222222
let builder = match config.flavor {
223223
RuntimeFlavor::CurrentThread => quote! {
224-
pyo3_asyncio_0_21::tokio::re_exports::runtime::Builder::new_current_thread()
224+
pyo3_async_runtimes::tokio::re_exports::runtime::Builder::new_current_thread()
225225
},
226226
RuntimeFlavor::Threaded => quote! {
227-
pyo3_asyncio_0_21::tokio::re_exports::runtime::Builder::new_multi_thread()
227+
pyo3_async_runtimes::tokio::re_exports::runtime::Builder::new_multi_thread()
228228
},
229229
};
230230

@@ -240,8 +240,8 @@ fn parse_knobs(
240240

241241
let rt_init = match config.flavor {
242242
RuntimeFlavor::CurrentThread => quote! {
243-
std::thread::spawn(|| pyo3_asyncio_0_21::tokio::get_runtime().block_on(
244-
pyo3_asyncio_0_21::tokio::re_exports::pending::<()>()
243+
std::thread::spawn(|| pyo3_async_runtimes::tokio::get_runtime().block_on(
244+
pyo3_async_runtimes::tokio::re_exports::pending::<()>()
245245
));
246246
},
247247
_ => quote! {},
@@ -259,12 +259,12 @@ fn parse_knobs(
259259
let mut builder = #builder;
260260
#builder_init;
261261

262-
pyo3_asyncio_0_21::tokio::init(builder);
262+
pyo3_async_runtimes::tokio::init(builder);
263263

264264
#rt_init
265265

266266
pyo3::Python::with_gil(|py| {
267-
pyo3_asyncio_0_21::tokio::run(py, main())
267+
pyo3_async_runtimes::tokio::run(py, main())
268268
.map_err(|e| {
269269
e.print_and_set_sys_last_vars(py);
270270
})

pytests/common/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{thread, time::Duration};
22

33
use pyo3::prelude::*;
4-
use pyo3_asyncio_0_21::TaskLocals;
4+
use pyo3_async_runtimes::TaskLocals;
55

66
pub(super) const TEST_MOD: &'static str = r#"
77
import asyncio
@@ -18,7 +18,7 @@ pub(super) async fn test_into_future(event_loop: PyObject) -> PyResult<()> {
1818
let test_mod =
1919
PyModule::from_code_bound(py, TEST_MOD, "test_rust_coroutine/test_mod.py", "test_mod")?;
2020

21-
pyo3_asyncio_0_21::into_future_with_locals(
21+
pyo3_async_runtimes::into_future_with_locals(
2222
&TaskLocals::new(event_loop.into_bound(py)),
2323
test_mod.call_method1("py_sleep", (1.into_py(py),))?,
2424
)
@@ -48,7 +48,7 @@ pub(super) async fn test_other_awaitables(event_loop: PyObject) -> PyResult<()>
4848
),
4949
)?;
5050

51-
pyo3_asyncio_0_21::into_future_with_locals(
51+
pyo3_async_runtimes::into_future_with_locals(
5252
&TaskLocals::new(event_loop.into_bound(py)),
5353
task,
5454
)

0 commit comments

Comments
 (0)