|
1 | | -use crate::prelude::*; |
| 1 | +use crate::{prelude::*, py::future::from_py_future}; |
2 | 2 |
|
3 | 3 | use pyo3::{ |
4 | 4 | Bound, IntoPyObjectExt, Py, PyAny, Python, pyclass, pymethods, |
@@ -93,10 +93,7 @@ impl interface::SimpleFunctionExecutor for Arc<PyFunctionExecutor> { |
93 | 93 | let result_coro = self.call_py_fn(py, input)?; |
94 | 94 | let task_locals = |
95 | 95 | pyo3_async_runtimes::TaskLocals::new(self.py_exec_ctx.event_loop.bind(py).clone()); |
96 | | - Ok(pyo3_async_runtimes::into_future_with_locals( |
97 | | - &task_locals, |
98 | | - result_coro, |
99 | | - )?) |
| 96 | + Ok(from_py_future(py, &task_locals, result_coro)?) |
100 | 97 | })?; |
101 | 98 | let result = result_fut.await; |
102 | 99 | Python::with_gil(|py| -> Result<_> { |
@@ -188,7 +185,8 @@ impl interface::SimpleFunctionFactory for PyFunctionFactory { |
188 | 185 | let prepare_coro = executor |
189 | 186 | .call_method(py, "prepare", (), None) |
190 | 187 | .to_result_with_py_trace(py)?; |
191 | | - let prepare_fut = pyo3_async_runtimes::into_future_with_locals( |
| 188 | + let prepare_fut = from_py_future( |
| 189 | + py, |
192 | 190 | &pyo3_async_runtimes::TaskLocals::new( |
193 | 191 | py_exec_ctx.event_loop.bind(py).clone(), |
194 | 192 | ), |
@@ -294,7 +292,8 @@ impl interface::SourceExecutor for PySourceExecutor { |
294 | 292 | .to_result_with_py_trace(py)?; |
295 | 293 | let task_locals = |
296 | 294 | pyo3_async_runtimes::TaskLocals::new(py_exec_ctx.event_loop.bind(py).clone()); |
297 | | - Ok(pyo3_async_runtimes::into_future_with_locals( |
| 295 | + Ok(from_py_future( |
| 296 | + py, |
298 | 297 | &task_locals, |
299 | 298 | result_coro.into_bound(py), |
300 | 299 | )?) |
@@ -333,10 +332,7 @@ impl PySourceExecutor { |
333 | 332 | .to_result_with_py_trace(py)?; |
334 | 333 | let task_locals = |
335 | 334 | pyo3_async_runtimes::TaskLocals::new(py_exec_ctx.event_loop.bind(py).clone()); |
336 | | - Ok(pyo3_async_runtimes::into_future_with_locals( |
337 | | - &task_locals, |
338 | | - coro.into_bound(py), |
339 | | - )?) |
| 335 | + Ok(from_py_future(py, &task_locals, coro.into_bound(py))?) |
340 | 336 | })?; |
341 | 337 |
|
342 | 338 | // Await the future to get the next item |
@@ -523,10 +519,7 @@ impl interface::SourceFactory for PySourceConnectorFactory { |
523 | 519 | .to_result_with_py_trace(py)?; |
524 | 520 | let task_locals = |
525 | 521 | pyo3_async_runtimes::TaskLocals::new(py_exec_ctx.event_loop.bind(py).clone()); |
526 | | - let create_future = pyo3_async_runtimes::into_future_with_locals( |
527 | | - &task_locals, |
528 | | - create_coro.into_bound(py), |
529 | | - )?; |
| 522 | + let create_future = from_py_future(py, &task_locals, create_coro.into_bound(py))?; |
530 | 523 | Ok(create_future) |
531 | 524 | })?; |
532 | 525 |
|
@@ -671,7 +664,8 @@ impl interface::TargetFactory for PyExportTargetFactory { |
671 | 664 | let task_locals = pyo3_async_runtimes::TaskLocals::new( |
672 | 665 | py_exec_ctx.event_loop.bind(py).clone(), |
673 | 666 | ); |
674 | | - anyhow::Ok(pyo3_async_runtimes::into_future_with_locals( |
| 667 | + anyhow::Ok(from_py_future( |
| 668 | + py, |
675 | 669 | &task_locals, |
676 | 670 | prepare_coro.into_bound(py), |
677 | 671 | )?) |
@@ -807,7 +801,8 @@ impl interface::TargetFactory for PyExportTargetFactory { |
807 | 801 | .to_result_with_py_trace(py)?; |
808 | 802 | let task_locals = |
809 | 803 | pyo3_async_runtimes::TaskLocals::new(py_exec_ctx.event_loop.bind(py).clone()); |
810 | | - Ok(pyo3_async_runtimes::into_future_with_locals( |
| 804 | + Ok(from_py_future( |
| 805 | + py, |
811 | 806 | &task_locals, |
812 | 807 | result_coro.into_bound(py), |
813 | 808 | )?) |
@@ -867,7 +862,8 @@ impl interface::TargetFactory for PyExportTargetFactory { |
867 | 862 | .to_result_with_py_trace(py)?; |
868 | 863 | let task_locals = |
869 | 864 | pyo3_async_runtimes::TaskLocals::new(py_exec_ctx.event_loop.bind(py).clone()); |
870 | | - Ok(pyo3_async_runtimes::into_future_with_locals( |
| 865 | + Ok(from_py_future( |
| 866 | + py, |
871 | 867 | &task_locals, |
872 | 868 | result_coro.into_bound(py), |
873 | 869 | )?) |
|
0 commit comments