Skip to content

Commit ea27ed2

Browse files
author
Andrew J Westlake
committed
Split re-exports into submodules so they don't get mixed with the public API
1 parent 2db5c97 commit ea27ed2

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

pyo3-asyncio-macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub fn async_std_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
146146
#body
147147
}
148148

149-
Box::pin(pyo3_asyncio::async_std::spawn_blocking(move || {
149+
Box::pin(pyo3_asyncio::async_std::re_exports::spawn_blocking(move || {
150150
#name()
151151
}))
152152
}

pyo3-asyncio-macros/src/tokio.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ fn parse_knobs(
221221

222222
let mut rt = match config.flavor {
223223
RuntimeFlavor::CurrentThread => quote! {
224-
pyo3_asyncio::tokio::runtime::Builder::new_current_thread()
224+
pyo3_asyncio::tokio::re_exports::runtime::Builder::new_current_thread()
225225
},
226226
RuntimeFlavor::Threaded => quote! {
227-
pyo3_asyncio::tokio::runtime::Builder::new_multi_thread()
227+
pyo3_asyncio::tokio::re_exports::runtime::Builder::new_multi_thread()
228228
},
229229
};
230230
if let Some(v) = config.worker_threads {
@@ -234,7 +234,7 @@ fn parse_knobs(
234234
let rt_init = match config.flavor {
235235
RuntimeFlavor::CurrentThread => quote! {
236236
std::thread::spawn(|| pyo3_asyncio::tokio::get_runtime().block_on(
237-
pyo3_asyncio::tokio::pending::<()>()
237+
pyo3_asyncio::tokio::re_exports::pending::<()>()
238238
));
239239
},
240240
_ => quote! {},

src/async_std.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ use pyo3::prelude::*;
55

66
use crate::generic::{self, JoinError, Runtime};
77

8-
/// re-export spawn_blocking for use in `#[test]` macro without external dependency
9-
pub use async_std::task::spawn_blocking;
8+
/// <span class="module-item stab portability" style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"><code>attributes</code></span>
9+
/// re-exports for macros
10+
#[cfg(feature = "attributes")]
11+
pub mod re_exports {
12+
/// re-export spawn_blocking for use in `#[test]` macro without external dependency
13+
pub use async_std::task::spawn_blocking;
14+
}
1015

1116
/// <span class="module-item stab portability" style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"><code>attributes</code></span> Provides the boilerplate for the `async-std` runtime and runs an async fn as main
1217
#[cfg(feature = "attributes")]

src/tokio.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ use ::tokio::{
44
runtime::{Builder, Runtime},
55
task,
66
};
7+
use futures::future::pending;
78
use once_cell::sync::OnceCell;
89
use pyo3::prelude::*;
910

1011
use crate::generic;
1112

12-
/// re-export pending to be used in tokio macros without additional dependency
13-
pub use futures::future::pending;
14-
/// re-export tokio::runtime to build runtimes in tokio macros without additional dependency
15-
pub use tokio::runtime;
13+
/// <span class="module-item stab portability" style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"><code>attributes</code></span>
14+
/// re-exports for macros
15+
#[cfg(feature = "attributes")]
16+
pub mod re_exports {
17+
/// re-export pending to be used in tokio macros without additional dependency
18+
pub use futures::future::pending;
19+
/// re-export tokio::runtime to build runtimes in tokio macros without additional dependency
20+
pub use tokio::runtime;
21+
}
1622

1723
/// <span class="module-item stab portability" style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;"><code>attributes</code></span>
1824
#[cfg(feature = "attributes")]

0 commit comments

Comments
 (0)