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]
@@ -478,13 +478,13 @@ where
478
478
/// via [`into_future`] (new behaviour in `v0.15`).
479
479
///
480
480
/// > Although `contextvars` are preserved for async Python functions, synchronous functions will
481
- /// unfortunately fail to resolve them when called within the Rust future. This is because the
482
- /// function is being called from a Rust thread, not inside an actual Python coroutine context.
481
+ /// > unfortunately fail to resolve them when called within the Rust future. This is because the
482
+ /// > function is being called from a Rust thread, not inside an actual Python coroutine context.
483
483
/// >
484
484
/// > As a workaround, you can get the `contextvars` from the current task locals using
485
- /// [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your
486
- /// synchronous function in a call to `contextvars.Context.run`. This will set the context, call the
487
- /// synchronous function, and restore the previous context when it returns or raises an exception.
485
+ /// > [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your
486
+ /// > synchronous function in a call to `contextvars.Context.run`. This will set the context, call the
487
+ /// > synchronous function, and restore the previous context when it returns or raises an exception.
488
488
///
489
489
/// # Arguments
490
490
/// * `py` - PyO3 GIL guard
@@ -655,7 +655,7 @@ fn get_panic_message(any: &dyn std::any::Any) -> &str {
655
655
if let Some ( str_slice) = any. downcast_ref :: < & str > ( ) {
656
656
str_slice
657
657
} else if let Some ( string) = any. downcast_ref :: < String > ( ) {
658
- string
658
+ string. as_str ( )
659
659
} else {
660
660
"unknown error"
661
661
}
@@ -751,13 +751,13 @@ impl PyDoneCallback {
751
751
/// via [`into_future`] (new behaviour in `v0.15`).
752
752
///
753
753
/// > Although `contextvars` are preserved for async Python functions, synchronous functions will
754
- /// unfortunately fail to resolve them when called within the Rust future. This is because the
755
- /// function is being called from a Rust thread, not inside an actual Python coroutine context.
754
+ /// > unfortunately fail to resolve them when called within the Rust future. This is because the
755
+ /// > function is being called from a Rust thread, not inside an actual Python coroutine context.
756
756
/// >
757
757
/// > As a workaround, you can get the `contextvars` from the current task locals using
758
- /// [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your
759
- /// synchronous function in a call to `contextvars.Context.run`. This will set the context, call the
760
- /// synchronous function, and restore the previous context when it returns or raises an exception.
758
+ /// > [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your
759
+ /// > synchronous function in a call to `contextvars.Context.run`. This will set the context, call the
760
+ /// > synchronous function, and restore the previous context when it returns or raises an exception.
761
761
///
762
762
/// # Arguments
763
763
/// * `py` - The current PyO3 GIL guard
@@ -859,13 +859,13 @@ where
859
859
/// via [`into_future`] (new behaviour in `v0.15`).
860
860
///
861
861
/// > Although `contextvars` are preserved for async Python functions, synchronous functions will
862
- /// unfortunately fail to resolve them when called within the Rust future. This is because the
863
- /// function is being called from a Rust thread, not inside an actual Python coroutine context.
862
+ /// > unfortunately fail to resolve them when called within the Rust future. This is because the
863
+ /// > function is being called from a Rust thread, not inside an actual Python coroutine context.
864
864
/// >
865
865
/// > As a workaround, you can get the `contextvars` from the current task locals using
866
- /// [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your
867
- /// synchronous function in a call to `contextvars.Context.run`. This will set the context, call the
868
- /// synchronous function, and restore the previous context when it returns or raises an exception.
866
+ /// > [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your
867
+ /// > synchronous function in a call to `contextvars.Context.run`. This will set the context, call the
868
+ /// > synchronous function, and restore the previous context when it returns or raises an exception.
869
869
///
870
870
/// # Arguments
871
871
/// * `py` - PyO3 GIL guard
@@ -1065,13 +1065,13 @@ where
1065
1065
/// via [`into_future`] (new behaviour in `v0.15`).
1066
1066
///
1067
1067
/// > Although `contextvars` are preserved for async Python functions, synchronous functions will
1068
- /// unfortunately fail to resolve them when called within the Rust future. This is because the
1069
- /// function is being called from a Rust thread, not inside an actual Python coroutine context.
1068
+ /// > unfortunately fail to resolve them when called within the Rust future. This is because the
1069
+ /// > function is being called from a Rust thread, not inside an actual Python coroutine context.
1070
1070
/// >
1071
1071
/// > As a workaround, you can get the `contextvars` from the current task locals using
1072
- /// [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your
1073
- /// synchronous function in a call to `contextvars.Context.run`. This will set the context, call the
1074
- /// synchronous function, and restore the previous context when it returns or raises an exception.
1072
+ /// > [`get_current_locals`] and [`TaskLocals::context`](`crate::TaskLocals::context`), then wrap your
1073
+ /// > synchronous function in a call to `contextvars.Context.run`. This will set the context, call the
1074
+ /// > synchronous function, and restore the previous context when it returns or raises an exception.
1075
1075
///
1076
1076
/// # Arguments
1077
1077
/// * `py` - The current PyO3 GIL guard
@@ -1446,11 +1446,14 @@ where
1446
1446
into_stream_with_locals_v1 :: < R > ( get_current_locals :: < R > ( gen. py ( ) ) ?, gen)
1447
1447
}
1448
1448
1449
+ #[ allow( dead_code) ]
1449
1450
fn py_true ( ) -> PyObject {
1450
1451
static TRUE : OnceCell < PyObject > = OnceCell :: new ( ) ;
1451
1452
TRUE . get_or_init ( || Python :: with_gil ( |py| true . into_py ( py) ) )
1452
1453
. clone ( )
1453
1454
}
1455
+
1456
+ #[ allow( dead_code) ]
1454
1457
fn py_false ( ) -> PyObject {
1455
1458
static FALSE : OnceCell < PyObject > = OnceCell :: new ( ) ;
1456
1459
FALSE
@@ -1463,6 +1466,7 @@ trait Sender: Send + 'static {
1463
1466
fn close ( & mut self ) -> PyResult < ( ) > ;
1464
1467
}
1465
1468
1469
+ #[ allow( dead_code) ]
1466
1470
struct GenericSender < R >
1467
1471
where
1468
1472
R : Runtime ,
0 commit comments