Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Oct 8, 2024
1 parent 71f5709 commit 780b502
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn rust_sleep(py: Python) -> PyResult<Bound<PyAny>> {
}

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

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

#[pymodule]
fn my_async_module(py: Python, m: &PyModule) -> PyResult<()> {
fn my_async_module(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(rust_sleep, m)?)?;
Ok(())
}
Expand Down Expand Up @@ -453,7 +453,7 @@ fn rust_sleep(py: Python) -> PyResult<Bound<PyAny>> {
}

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

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions pytests/test_async_std_asyncio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ fn test_local_cancel(event_loop: PyObject) -> PyResult<()> {

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

#[pymodule]
fn cvars_mod(_py: Python, m: &PyModule) -> PyResult<()> {
fn cvars_mod(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
#![allow(deprecated)]
#[pyfunction]
pub(crate) fn async_callback(py: Python, callback: PyObject) -> PyResult<Bound<PyAny>> {
Expand Down
4 changes: 2 additions & 2 deletions pytests/tokio_asyncio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fn test_local_cancel(event_loop: PyObject) -> PyResult<()> {

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

#[pymodule]
fn cvars_mod(_py: Python, m: &PyModule) -> PyResult<()> {
fn cvars_mod(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
#![allow(deprecated)]
#[pyfunction]
fn async_callback(py: Python, callback: PyObject) -> PyResult<Bound<PyAny>> {
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
//! let locals = pyo3_async_runtimes::TaskLocals::with_running_loop(py)?.copy_context(py)?;
//!
//! // Convert the async move { } block to a Python awaitable
//! pyo3_async_runtimes::tokio::future_into_py_with_locals(py, locals.clone(), async move {
//! pyo3_async_runtimes::tokio::future_into_py_with_locals(py, locals.clone_ref(py), async move {
//! let py_sleep = Python::with_gil(|py| {
//! // Sometimes we need to call other async Python functions within
//! // this future. In order for this to work, we need to track the
Expand All @@ -112,7 +112,7 @@
//!
//! # #[cfg(feature = "tokio-runtime")]
//! #[pymodule]
//! fn my_mod(py: Python, m: &PyModule) -> PyResult<()> {
//! fn my_mod(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
//! m.add_function(wrap_pyfunction!(sleep, m)?)?;
//! Ok(())
//! }
Expand Down Expand Up @@ -162,9 +162,9 @@
//!
//! pyo3_async_runtimes::tokio::future_into_py_with_locals(
//! py,
//! locals.clone(),
//! locals.clone_ref(py),
//! // Store the current locals in task-local data
//! pyo3_async_runtimes::tokio::scope(locals.clone(), async move {
//! pyo3_async_runtimes::tokio::scope(locals.clone_ref(py), async move {
//! let py_sleep = Python::with_gil(|py| {
//! pyo3_async_runtimes::into_future_with_locals(
//! // Now we can get the current locals through task-local data
Expand All @@ -189,9 +189,9 @@
//!
//! pyo3_async_runtimes::tokio::future_into_py_with_locals(
//! py,
//! locals.clone(),
//! locals.clone_ref(py),
//! // Store the current locals in task-local data
//! pyo3_async_runtimes::tokio::scope(locals.clone(), async move {
//! pyo3_async_runtimes::tokio::scope(locals.clone_ref(py), async move {
//! let py_sleep = Python::with_gil(|py| {
//! pyo3_async_runtimes::into_future_with_locals(
//! &pyo3_async_runtimes::tokio::get_current_locals(py)?,
Expand All @@ -210,7 +210,7 @@
//!
//! # #[cfg(feature = "tokio-runtime")]
//! #[pymodule]
//! fn my_mod(py: Python, m: &PyModule) -> PyResult<()> {
//! fn my_mod(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
//! m.add_function(wrap_pyfunction!(sleep, m)?)?;
//! m.add_function(wrap_pyfunction!(wrap_sleep, m)?)?;
//! Ok(())
Expand Down Expand Up @@ -270,7 +270,7 @@
//!
//! # #[cfg(feature = "tokio-runtime")]
//! #[pymodule]
//! fn my_mod(py: Python, m: &PyModule) -> PyResult<()> {
//! fn my_mod(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
//! m.add_function(wrap_pyfunction!(sleep, m)?)?;
//! m.add_function(wrap_pyfunction!(wrap_sleep, m)?)?;
//! Ok(())
Expand Down

0 comments on commit 780b502

Please sign in to comment.