Skip to content

Commit fd70e99

Browse files
Fix tests
1 parent dd4f0a6 commit fd70e99

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fn rust_sleep(py: Python) -> PyResult<Bound<PyAny>> {
159159
}
160160

161161
#[pymodule]
162-
fn my_async_module(py: Python, m: &PyModule) -> PyResult<()> {
162+
fn my_async_module(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
163163
m.add_function(wrap_pyfunction!(rust_sleep, m)?)?;
164164

165165
Ok(())
@@ -183,7 +183,7 @@ fn rust_sleep(py: Python) -> PyResult<Bound<PyAny>> {
183183
}
184184

185185
#[pymodule]
186-
fn my_async_module(py: Python, m: &PyModule) -> PyResult<()> {
186+
fn my_async_module(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
187187
m.add_function(wrap_pyfunction!(rust_sleep, m)?)?;
188188
Ok(())
189189
}
@@ -453,7 +453,7 @@ fn rust_sleep(py: Python) -> PyResult<Bound<PyAny>> {
453453
}
454454

455455
#[pymodule]
456-
fn my_async_module(_py: Python, m: &PyModule) -> PyResult<()> {
456+
fn my_async_module(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
457457
m.add_function(wrap_pyfunction!(rust_sleep, m)?)?;
458458

459459
Ok(())

pytests/test_async_std_asyncio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ fn test_local_cancel(event_loop: PyObject) -> PyResult<()> {
262262

263263
/// This module is implemented in Rust.
264264
#[pymodule]
265-
fn test_mod(_py: Python, m: &PyModule) -> PyResult<()> {
265+
fn test_mod(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
266266
#![allow(deprecated)]
267267
#[pyfunction(name = "sleep")]
268268
fn sleep_(py: Python) -> PyResult<Bound<PyAny>> {
@@ -309,7 +309,7 @@ fn test_multiple_asyncio_run() -> PyResult<()> {
309309
}
310310

311311
#[pymodule]
312-
fn cvars_mod(_py: Python, m: &PyModule) -> PyResult<()> {
312+
fn cvars_mod(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
313313
#![allow(deprecated)]
314314
#[pyfunction]
315315
pub(crate) fn async_callback(py: Python, callback: PyObject) -> PyResult<Bound<PyAny>> {

pytests/tokio_asyncio/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ fn test_local_cancel(event_loop: PyObject) -> PyResult<()> {
240240

241241
/// This module is implemented in Rust.
242242
#[pymodule]
243-
fn test_mod(_py: Python, m: &PyModule) -> PyResult<()> {
243+
fn test_mod(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
244244
#![allow(deprecated)]
245245
#[pyfunction(name = "sleep")]
246246
fn sleep_(py: Python) -> PyResult<Bound<PyAny>> {
@@ -287,7 +287,7 @@ fn test_multiple_asyncio_run() -> PyResult<()> {
287287
}
288288

289289
#[pymodule]
290-
fn cvars_mod(_py: Python, m: &PyModule) -> PyResult<()> {
290+
fn cvars_mod(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
291291
#![allow(deprecated)]
292292
#[pyfunction]
293293
fn async_callback(py: Python, callback: PyObject) -> PyResult<Bound<PyAny>> {

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
//! let locals = pyo3_async_runtimes::TaskLocals::with_running_loop(py)?.copy_context(py)?;
9494
//!
9595
//! // Convert the async move { } block to a Python awaitable
96-
//! pyo3_async_runtimes::tokio::future_into_py_with_locals(py, locals.clone(), async move {
96+
//! pyo3_async_runtimes::tokio::future_into_py_with_locals(py, locals.clone_ref(py), async move {
9797
//! let py_sleep = Python::with_gil(|py| {
9898
//! // Sometimes we need to call other async Python functions within
9999
//! // this future. In order for this to work, we need to track the
@@ -112,7 +112,7 @@
112112
//!
113113
//! # #[cfg(feature = "tokio-runtime")]
114114
//! #[pymodule]
115-
//! fn my_mod(py: Python, m: &PyModule) -> PyResult<()> {
115+
//! fn my_mod(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
116116
//! m.add_function(wrap_pyfunction!(sleep, m)?)?;
117117
//! Ok(())
118118
//! }
@@ -162,9 +162,9 @@
162162
//!
163163
//! pyo3_async_runtimes::tokio::future_into_py_with_locals(
164164
//! py,
165-
//! locals.clone(),
165+
//! locals.clone_ref(py),
166166
//! // Store the current locals in task-local data
167-
//! pyo3_async_runtimes::tokio::scope(locals.clone(), async move {
167+
//! pyo3_async_runtimes::tokio::scope(locals.clone_ref(py), async move {
168168
//! let py_sleep = Python::with_gil(|py| {
169169
//! pyo3_async_runtimes::into_future_with_locals(
170170
//! // Now we can get the current locals through task-local data
@@ -189,9 +189,9 @@
189189
//!
190190
//! pyo3_async_runtimes::tokio::future_into_py_with_locals(
191191
//! py,
192-
//! locals.clone(),
192+
//! locals.clone_ref(py),
193193
//! // Store the current locals in task-local data
194-
//! pyo3_async_runtimes::tokio::scope(locals.clone(), async move {
194+
//! pyo3_async_runtimes::tokio::scope(locals.clone_ref(py), async move {
195195
//! let py_sleep = Python::with_gil(|py| {
196196
//! pyo3_async_runtimes::into_future_with_locals(
197197
//! &pyo3_async_runtimes::tokio::get_current_locals(py)?,
@@ -210,7 +210,7 @@
210210
//!
211211
//! # #[cfg(feature = "tokio-runtime")]
212212
//! #[pymodule]
213-
//! fn my_mod(py: Python, m: &PyModule) -> PyResult<()> {
213+
//! fn my_mod(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
214214
//! m.add_function(wrap_pyfunction!(sleep, m)?)?;
215215
//! m.add_function(wrap_pyfunction!(wrap_sleep, m)?)?;
216216
//! Ok(())
@@ -270,7 +270,7 @@
270270
//!
271271
//! # #[cfg(feature = "tokio-runtime")]
272272
//! #[pymodule]
273-
//! fn my_mod(py: Python, m: &PyModule) -> PyResult<()> {
273+
//! fn my_mod(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
274274
//! m.add_function(wrap_pyfunction!(sleep, m)?)?;
275275
//! m.add_function(wrap_pyfunction!(wrap_sleep, m)?)?;
276276
//! Ok(())

0 commit comments

Comments
 (0)