|
93 | 93 | //! let locals = pyo3_async_runtimes::TaskLocals::with_running_loop(py)?.copy_context(py)?; |
94 | 94 | //! |
95 | 95 | //! // 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 { |
97 | 97 | //! let py_sleep = Python::with_gil(|py| { |
98 | 98 | //! // Sometimes we need to call other async Python functions within |
99 | 99 | //! // this future. In order for this to work, we need to track the |
|
112 | 112 | //! |
113 | 113 | //! # #[cfg(feature = "tokio-runtime")] |
114 | 114 | //! #[pymodule] |
115 | | -//! fn my_mod(py: Python, m: &PyModule) -> PyResult<()> { |
| 115 | +//! fn my_mod(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { |
116 | 116 | //! m.add_function(wrap_pyfunction!(sleep, m)?)?; |
117 | 117 | //! Ok(()) |
118 | 118 | //! } |
|
162 | 162 | //! |
163 | 163 | //! pyo3_async_runtimes::tokio::future_into_py_with_locals( |
164 | 164 | //! py, |
165 | | -//! locals.clone(), |
| 165 | +//! locals.clone_ref(py), |
166 | 166 | //! // 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 { |
168 | 168 | //! let py_sleep = Python::with_gil(|py| { |
169 | 169 | //! pyo3_async_runtimes::into_future_with_locals( |
170 | 170 | //! // Now we can get the current locals through task-local data |
|
189 | 189 | //! |
190 | 190 | //! pyo3_async_runtimes::tokio::future_into_py_with_locals( |
191 | 191 | //! py, |
192 | | -//! locals.clone(), |
| 192 | +//! locals.clone_ref(py), |
193 | 193 | //! // 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 { |
195 | 195 | //! let py_sleep = Python::with_gil(|py| { |
196 | 196 | //! pyo3_async_runtimes::into_future_with_locals( |
197 | 197 | //! &pyo3_async_runtimes::tokio::get_current_locals(py)?, |
|
210 | 210 | //! |
211 | 211 | //! # #[cfg(feature = "tokio-runtime")] |
212 | 212 | //! #[pymodule] |
213 | | -//! fn my_mod(py: Python, m: &PyModule) -> PyResult<()> { |
| 213 | +//! fn my_mod(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { |
214 | 214 | //! m.add_function(wrap_pyfunction!(sleep, m)?)?; |
215 | 215 | //! m.add_function(wrap_pyfunction!(wrap_sleep, m)?)?; |
216 | 216 | //! Ok(()) |
|
270 | 270 | //! |
271 | 271 | //! # #[cfg(feature = "tokio-runtime")] |
272 | 272 | //! #[pymodule] |
273 | | -//! fn my_mod(py: Python, m: &PyModule) -> PyResult<()> { |
| 273 | +//! fn my_mod(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { |
274 | 274 | //! m.add_function(wrap_pyfunction!(sleep, m)?)?; |
275 | 275 | //! m.add_function(wrap_pyfunction!(wrap_sleep, m)?)?; |
276 | 276 | //! Ok(()) |
|
0 commit comments