@@ -44,7 +44,7 @@ pub trait SpawnLocalExt: Runtime {
44
44
45
45
/// Exposes the utilities necessary for using task-local data in the Runtime
46
46
pub trait ContextExt : Runtime {
47
- /// Set the task local event loop for the given future
47
+ /// Set the task locals for the given future
48
48
fn scope < F , R > ( locals : TaskLocals , fut : F ) -> Pin < Box < dyn Future < Output = R > + Send > >
49
49
where
50
50
F : Future < Output = R > + Send + ' static ;
@@ -55,7 +55,7 @@ pub trait ContextExt: Runtime {
55
55
56
56
/// Adds the ability to scope task-local data for !Send futures
57
57
pub trait LocalContextExt : Runtime {
58
- /// Set the task local event loop for the given !Send future
58
+ /// Set the task locals for the given !Send future
59
59
fn scope_local < F , R > ( locals : TaskLocals , fut : F ) -> Pin < Box < dyn Future < Output = R > > >
60
60
where
61
61
F : Future < Output = R > + ' static ;
@@ -310,9 +310,9 @@ fn set_result(event_loop: &PyAny, future: &PyAny, result: PyResult<PyObject>) ->
310
310
311
311
/// Convert a Python `awaitable` into a Rust Future
312
312
///
313
- /// This function simply forwards the future and the `event_loop` returned by [`get_current_loop `]
314
- /// to [`into_future_with_loop `](`crate::into_future_with_loop `). See
315
- /// [`into_future_with_loop `](`crate::into_future_with_loop `) for more details.
313
+ /// This function simply forwards the future and the task locals returned by [`get_current_locals `]
314
+ /// to [`into_future_with_locals `](`crate::into_future_with_locals `). See
315
+ /// [`into_future_with_locals `](`crate::into_future_with_locals `) for more details.
316
316
///
317
317
/// # Arguments
318
318
/// * `awaitable` - The Python `awaitable` to be converted
@@ -422,6 +422,7 @@ where
422
422
/// Convert a Rust Future into a Python awaitable with a generic runtime
423
423
///
424
424
/// # Arguments
425
+ /// * `py` - PyO3 GIL guard
425
426
/// * `locals` - The task-local data for Python
426
427
/// * `fut` - The Rust future to be converted
427
428
///
@@ -579,6 +580,8 @@ where
579
580
580
581
/// Convert a Rust Future into a Python awaitable with a generic runtime
581
582
///
583
+ /// __
584
+ ///
582
585
/// # Arguments
583
586
/// * `event_loop` - The Python event loop that the awaitable should be attached to
584
587
/// * `fut` - The Rust future to be converted
@@ -760,12 +763,11 @@ impl PyDoneCallback {
760
763
761
764
/// Convert a Rust Future into a Python awaitable with a generic runtime
762
765
///
763
- /// Unlike [`future_into_py_with_loop`], this function will stop the Rust future from running when
764
- /// the `asyncio.Future` is cancelled from Python.
766
+ /// __This function was deprecated in favor of [`future_into_py_with_locals`] in `v0.15` because
767
+ /// it became the default behaviour. In `v0.15`, any calls to this function can be seamlessly
768
+ /// replaced with [`future_into_py_with_locals`].__
765
769
///
766
- /// __This function will be deprecated in favor of [`future_into_py_with_loop`] in `v0.15` because
767
- /// it will become the default behaviour. In `v0.15`, any calls to this function can be seamlessly
768
- /// replaced with [`future_into_py_with_loop`].__
770
+ /// __In `v0.16` this function will be removed__
769
771
///
770
772
/// # Arguments
771
773
/// * `event_loop` - The Python event loop that the awaitable should be attached to
@@ -954,13 +956,12 @@ where
954
956
955
957
/// Convert a Rust Future into a Python awaitable with a generic runtime
956
958
///
957
- /// Unlike [`future_into_py`], this function will stop the Rust future from running when the
958
- /// `asyncio.Future` is cancelled from Python.
959
- ///
960
- /// __This function will be deprecated in favor of [`future_into_py`] in `v0.15` because
961
- /// it will become the default behaviour. In `v0.15`, any calls to this function can be seamlessly
959
+ /// __This function was deprecated in favor of [`future_into_py`] in `v0.15` because
960
+ /// it became the default behaviour. In `v0.15`, any calls to this function can be seamlessly
962
961
/// replaced with [`future_into_py`].__
963
962
///
963
+ /// __In `v0.16` this function will be removed__
964
+ ///
964
965
/// # Arguments
965
966
/// * `py` - The current PyO3 GIL guard
966
967
/// * `fut` - The Rust future to be converted
@@ -1051,10 +1052,12 @@ where
1051
1052
future_into_py :: < R , F , PyObject > ( py, fut)
1052
1053
}
1053
1054
1054
- /// Convert a `!Send` Rust Future into a Python awaitable with a generic runtime
1055
+ /// Convert a `!Send` Rust Future into a Python awaitable with a generic runtime and manual
1056
+ /// specification of task locals.
1055
1057
///
1056
1058
/// # Arguments
1057
- /// * `event_loop` - The Python event loop that the awaitable should be attached to
1059
+ /// * `py` - PyO3 GIL guard
1060
+ /// * `locals` - The task locals for the future
1058
1061
/// * `fut` - The Rust future to be converted
1059
1062
///
1060
1063
/// # Examples
@@ -1231,6 +1234,8 @@ where
1231
1234
1232
1235
/// Convert a `!Send` Rust Future into a Python awaitable with a generic runtime
1233
1236
///
1237
+ /// __In `v0.16` this function will be removed__
1238
+ ///
1234
1239
/// # Arguments
1235
1240
/// * `event_loop` - The Python event loop that the awaitable should be attached to
1236
1241
/// * `fut` - The Rust future to be converted
@@ -1320,6 +1325,10 @@ where
1320
1325
/// )
1321
1326
/// }
1322
1327
/// ```
1328
+ #[ deprecated(
1329
+ since = "0.15.0" ,
1330
+ note = "Use pyo3_asyncio::generic::local_future_into_py_with_locals instead"
1331
+ ) ]
1323
1332
pub fn local_future_into_py_with_loop < R , F > ( event_loop : & PyAny , fut : F ) -> PyResult < & PyAny >
1324
1333
where
1325
1334
R : Runtime + SpawnLocalExt + LocalContextExt ,
@@ -1335,12 +1344,9 @@ where
1335
1344
1336
1345
/// Convert a `!Send` Rust Future into a Python awaitable with a generic runtime
1337
1346
///
1338
- /// Unlike [`local_future_into_py_with_loop`], this function will stop the Rust future from running
1339
- /// when the `asyncio.Future` is cancelled from Python.
1340
- ///
1341
- /// __This function will be deprecated in favor of [`local_future_into_py_with_loop`] in `v0.15` because
1342
- /// it will become the default behaviour. In `v0.15`, any calls to this function can be seamlessly
1343
- /// replaced with [`local_future_into_py_with_loop`].__
1347
+ /// __This function was deprecated in favor of [`local_future_into_py_with_locals`] in `v0.15` because
1348
+ /// it became the default behaviour. In `v0.15`, any calls to this function can be seamlessly
1349
+ /// replaced with [`local_future_into_py_with_locals`].__
1344
1350
///
1345
1351
/// # Arguments
1346
1352
/// * `event_loop` - The Python event loop that the awaitable should be attached to
@@ -1435,6 +1441,7 @@ where
1435
1441
since = "0.15.0" ,
1436
1442
note = "Use pyo3_asyncio::generic::local_future_into_py_with_locals instead"
1437
1443
) ]
1444
+ #[ allow( deprecated) ]
1438
1445
pub fn local_cancellable_future_into_py_with_loop < R , F > (
1439
1446
event_loop : & PyAny ,
1440
1447
fut : F ,
@@ -1560,8 +1567,8 @@ where
1560
1567
/// Unlike [`local_future_into_py`], this function will stop the Rust future from running when the
1561
1568
/// `asyncio.Future` is cancelled from Python.
1562
1569
///
1563
- /// __This function will be deprecated in favor of [`local_future_into_py`] in `v0.15` because
1564
- /// it will become the default behaviour. In `v0.15`, any calls to this function can be seamlessly
1570
+ /// __This function was deprecated in favor of [`local_future_into_py`] in `v0.15` because
1571
+ /// it became the default behaviour. In `v0.15`, any calls to this function can be seamlessly
1565
1572
/// replaced with [`local_future_into_py`].__
1566
1573
///
1567
1574
/// # Arguments
0 commit comments