|
5 | 5 | //! class="module-item stab portability" |
6 | 6 | //! style="display: inline; border-radius: 3px; padding: 2px; font-size: 80%; line-height: 1.2;" |
7 | 7 | //! ><code>unstable-streams</code></span> |
8 | | -//! are only available when the `unstable-streams` Cargo feature is enabled: |
| 8 | +//! >are only available when the `unstable-streams` Cargo feature is enabled: |
9 | 9 | //! |
10 | 10 | //! ```toml |
11 | 11 | //! [dependencies.pyo3-asyncio-0-21] |
@@ -176,6 +176,7 @@ pub fn init(builder: Builder) { |
176 | 176 | /// Initialize the Tokio runtime with a custom Tokio runtime |
177 | 177 | /// |
178 | 178 | /// Returns Ok(()) if success and Err(()) if it had been inited. |
| 179 | +#[allow(clippy::result_unit_err)] |
179 | 180 | pub fn init_with_runtime(runtime: &'static Runtime) -> Result<(), ()> { |
180 | 181 | TOKIO_RUNTIME |
181 | 182 | .set(Pyo3Runtime::Borrowed(runtime)) |
@@ -278,13 +279,13 @@ where |
278 | 279 | /// via [`into_future`] (new behaviour in `v0.15`). |
279 | 280 | /// |
280 | 281 | /// > Although `contextvars` are preserved for async Python functions, synchronous functions will |
281 | | -/// unfortunately fail to resolve them when called within the Rust future. This is because the |
282 | | -/// function is being called from a Rust thread, not inside an actual Python coroutine context. |
| 282 | +/// > unfortunately fail to resolve them when called within the Rust future. This is because the |
| 283 | +/// > function is being called from a Rust thread, not inside an actual Python coroutine context. |
283 | 284 | /// > |
284 | 285 | /// > As a workaround, you can get the `contextvars` from the current task locals using |
285 | | -/// [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your |
286 | | -/// synchronous function in a call to `contextvars.Context.run`. This will set the context, call the |
287 | | -/// synchronous function, and restore the previous context when it returns or raises an exception. |
| 286 | +/// > [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your |
| 287 | +/// > synchronous function in a call to `contextvars.Context.run`. This will set the context, call the |
| 288 | +/// > synchronous function, and restore the previous context when it returns or raises an exception. |
288 | 289 | /// |
289 | 290 | /// # Arguments |
290 | 291 | /// * `py` - PyO3 GIL guard |
@@ -333,13 +334,13 @@ where |
333 | 334 | /// via [`into_future`] (new behaviour in `v0.15`). |
334 | 335 | /// |
335 | 336 | /// > Although `contextvars` are preserved for async Python functions, synchronous functions will |
336 | | -/// unfortunately fail to resolve them when called within the Rust future. This is because the |
337 | | -/// function is being called from a Rust thread, not inside an actual Python coroutine context. |
| 337 | +/// > unfortunately fail to resolve them when called within the Rust future. This is because the |
| 338 | +/// > function is being called from a Rust thread, not inside an actual Python coroutine context. |
338 | 339 | /// > |
339 | 340 | /// > As a workaround, you can get the `contextvars` from the current task locals using |
340 | | -/// [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your |
341 | | -/// synchronous function in a call to `contextvars.Context.run`. This will set the context, call the |
342 | | -/// synchronous function, and restore the previous context when it returns or raises an exception. |
| 341 | +/// > [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your |
| 342 | +/// > synchronous function in a call to `contextvars.Context.run`. This will set the context, call the |
| 343 | +/// > synchronous function, and restore the previous context when it returns or raises an exception. |
343 | 344 | /// |
344 | 345 | /// # Arguments |
345 | 346 | /// * `py` - The current PyO3 GIL guard |
@@ -379,13 +380,13 @@ where |
379 | 380 | /// via [`into_future`] (new behaviour in `v0.15`). |
380 | 381 | /// |
381 | 382 | /// > Although `contextvars` are preserved for async Python functions, synchronous functions will |
382 | | -/// unfortunately fail to resolve them when called within the Rust future. This is because the |
383 | | -/// function is being called from a Rust thread, not inside an actual Python coroutine context. |
| 383 | +/// > unfortunately fail to resolve them when called within the Rust future. This is because the |
| 384 | +/// > function is being called from a Rust thread, not inside an actual Python coroutine context. |
384 | 385 | /// > |
385 | 386 | /// > As a workaround, you can get the `contextvars` from the current task locals using |
386 | | -/// [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your |
387 | | -/// synchronous function in a call to `contextvars.Context.run`. This will set the context, call the |
388 | | -/// synchronous function, and restore the previous context when it returns or raises an exception. |
| 387 | +/// > [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your |
| 388 | +/// > synchronous function in a call to `contextvars.Context.run`. This will set the context, call the |
| 389 | +/// > synchronous function, and restore the previous context when it returns or raises an exception. |
389 | 390 | /// |
390 | 391 | /// # Arguments |
391 | 392 | /// * `py` - PyO3 GIL guard |
@@ -470,13 +471,13 @@ where |
470 | 471 | /// via [`into_future`] (new behaviour in `v0.15`). |
471 | 472 | /// |
472 | 473 | /// > Although `contextvars` are preserved for async Python functions, synchronous functions will |
473 | | -/// unfortunately fail to resolve them when called within the Rust future. This is because the |
474 | | -/// function is being called from a Rust thread, not inside an actual Python coroutine context. |
| 474 | +/// > unfortunately fail to resolve them when called within the Rust future. This is because the |
| 475 | +/// > function is being called from a Rust thread, not inside an actual Python coroutine context. |
475 | 476 | /// > |
476 | 477 | /// > As a workaround, you can get the `contextvars` from the current task locals using |
477 | | -/// [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your |
478 | | -/// synchronous function in a call to `contextvars.Context.run`. This will set the context, call the |
479 | | -/// synchronous function, and restore the previous context when it returns or raises an exception. |
| 478 | +/// > [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your |
| 479 | +/// > synchronous function in a call to `contextvars.Context.run`. This will set the context, call the |
| 480 | +/// > synchronous function, and restore the previous context when it returns or raises an exception. |
480 | 481 | /// |
481 | 482 | /// # Arguments |
482 | 483 | /// * `py` - The current PyO3 GIL guard |
@@ -650,9 +651,9 @@ pub fn into_future( |
650 | 651 | /// # fn main() {} |
651 | 652 | /// ``` |
652 | 653 | #[cfg(feature = "unstable-streams")] |
653 | | -pub fn into_stream_with_locals_v1<'p>( |
| 654 | +pub fn into_stream_with_locals_v1( |
654 | 655 | locals: TaskLocals, |
655 | | - gen: Bound<'p, PyAny>, |
| 656 | + gen: Bound<'_, PyAny>, |
656 | 657 | ) -> PyResult<impl futures::Stream<Item = PyResult<PyObject>> + 'static> { |
657 | 658 | generic::into_stream_with_locals_v1::<TokioRuntime>(locals, gen) |
658 | 659 | } |
@@ -707,8 +708,8 @@ pub fn into_stream_with_locals_v1<'p>( |
707 | 708 | /// # fn main() {} |
708 | 709 | /// ``` |
709 | 710 | #[cfg(feature = "unstable-streams")] |
710 | | -pub fn into_stream_v1<'p>( |
711 | | - gen: Bound<'p, PyAny>, |
| 711 | +pub fn into_stream_v1( |
| 712 | + gen: Bound<'_, PyAny>, |
712 | 713 | ) -> PyResult<impl futures::Stream<Item = PyResult<PyObject>> + 'static> { |
713 | 714 | generic::into_stream_v1::<TokioRuntime>(gen) |
714 | 715 | } |
@@ -767,9 +768,9 @@ pub fn into_stream_v1<'p>( |
767 | 768 | /// # fn main() {} |
768 | 769 | /// ``` |
769 | 770 | #[cfg(feature = "unstable-streams")] |
770 | | -pub fn into_stream_with_locals_v2<'p>( |
| 771 | +pub fn into_stream_with_locals_v2( |
771 | 772 | locals: TaskLocals, |
772 | | - gen: Bound<'p, PyAny>, |
| 773 | + gen: Bound<'_, PyAny>, |
773 | 774 | ) -> PyResult<impl futures::Stream<Item = PyObject> + 'static> { |
774 | 775 | generic::into_stream_with_locals_v2::<TokioRuntime>(locals, gen) |
775 | 776 | } |
@@ -824,8 +825,8 @@ pub fn into_stream_with_locals_v2<'p>( |
824 | 825 | /// # fn main() {} |
825 | 826 | /// ``` |
826 | 827 | #[cfg(feature = "unstable-streams")] |
827 | | -pub fn into_stream_v2<'p>( |
828 | | - gen: Bound<'p, PyAny>, |
| 828 | +pub fn into_stream_v2( |
| 829 | + gen: Bound<'_, PyAny>, |
829 | 830 | ) -> PyResult<impl futures::Stream<Item = PyObject> + 'static> { |
830 | 831 | generic::into_stream_v2::<TokioRuntime>(gen) |
831 | 832 | } |
0 commit comments