Skip to content

Commit 76dd178

Browse files
committed
update method
1 parent 6e31661 commit 76dd178

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/dynamic/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::object::model::teo_model_object_to_py_any;
1616
use crate::object::py_any_to_teo_object;
1717
use crate::object::value::{teo_value_to_py_any, py_any_to_teo_value};
1818
use crate::result::{IntoPyResultWithGil, IntoTeoPathResult};
19-
use crate::utils::await_coroutine_if_needed::await_coroutine_if_needed_async_value;
19+
use crate::utils::await_coroutine_if_needed::await_coroutine_if_needed_value_with_locals;
2020
use crate::utils::check_py_dict::check_py_dict;
2121

2222
use self::model_ctx_wrapper::ModelCtxWrapper;
@@ -532,7 +532,7 @@ fn synthesize_direct_dynamic_nodejs_classes_for_namespace(py: Python<'_>, namesp
532532
let coroutine_or_value = shared_argument.call1(py, (ctx_python,)).into_teo_path_result()?;
533533
Ok::<PyObject, teo::prelude::path::Error>(coroutine_or_value)
534534
})?;
535-
Ok(await_coroutine_if_needed_async_value(user_retval, main_thread_locals).await.into_teo_path_result()?)
535+
Ok(await_coroutine_if_needed_value_with_locals(user_retval, main_thread_locals).await.into_teo_path_result()?)
536536
}).await.into_py_result_with_gil()?;
537537
Python::with_gil(|py| {
538538
Ok::<PyObject, PyErr>(retval.into_py(py))

src/handler/group.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::dynamic::py_ctx_object_from_teo_transaction_ctx;
55
use crate::object::value::teo_value_to_py_any;
66
use crate::request::request::Request;
77
use crate::response::Response;
8-
use crate::utils::await_coroutine_if_needed::await_coroutine_if_needed_async_value;
8+
use crate::utils::await_coroutine_if_needed::await_coroutine_if_needed_value_with_locals;
99
use crate::utils::check_callable::check_callable;
1010
use crate::result::IntoTeoPathResult;
1111

@@ -31,7 +31,7 @@ impl HandlerGroup {
3131
let result = callback_owned.call1(py, (request, body, py_ctx))?;
3232
Ok::<PyObject, PyErr>(result)
3333
}).into_teo_path_result()?;
34-
let awaited_result = await_coroutine_if_needed_async_value(result, main_thread_locals).await.into_teo_path_result()?;
34+
let awaited_result = await_coroutine_if_needed_value_with_locals(result, main_thread_locals).await.into_teo_path_result()?;
3535
Python::with_gil(|py| {
3636
let response: Response = awaited_result.extract(py).into_teo_path_result()?;
3737
Ok(response.teo_response.clone())

src/namespace/namespace.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use pyo3::{pyclass, pymethods, types::PyCFunction, IntoPy, Py, PyErr, PyObject, PyResult, Python};
22
use teo::prelude::{handler::Group as TeoHandlerGroup, model::Field as TeoField, model::Property as TeoProperty, model::Relation as TeoRelation, request, Enum as TeoEnum, Member as TeoEnumMember, Middleware, Model as TeoModel, Namespace as TeoNamespace, Next};
33

4-
use crate::{utils::{check_callable::check_callable, await_coroutine_if_needed::await_coroutine_if_needed_async_value}, object::{arguments::teo_args_to_py_args, value::teo_value_to_py_any}, model::{model::Model, field::field::Field, relation::relation::Relation, property::property::Property}, result::{IntoPyResultWithGil, IntoTeoPathResult, IntoTeoResult}, r#enum::{r#enum::Enum, member::member::EnumMember}, request::{Request, RequestCtx}, dynamic::py_ctx_object_from_teo_transaction_ctx, response::Response, handler::group::HandlerGroup};
4+
use crate::{utils::{check_callable::check_callable, await_coroutine_if_needed::await_coroutine_if_needed_value_with_locals}, object::{arguments::teo_args_to_py_args, value::teo_value_to_py_any}, model::{model::Model, field::field::Field, relation::relation::Relation, property::property::Property}, result::{IntoPyResultWithGil, IntoTeoPathResult, IntoTeoResult}, r#enum::{r#enum::Enum, member::member::EnumMember}, request::{Request, RequestCtx}, dynamic::py_ctx_object_from_teo_transaction_ctx, response::Response, handler::group::HandlerGroup};
55

66
#[pyclass]
77
pub struct Namespace {
@@ -165,7 +165,7 @@ impl Namespace {
165165
let result = callback_owned.call1(py, (request, body, py_ctx))?;
166166
Ok::<PyObject, PyErr>(result)
167167
}).into_teo_path_result()?;
168-
let awaited_result = await_coroutine_if_needed_async_value(result, main_thread_locals).await.into_teo_path_result()?;
168+
let awaited_result = await_coroutine_if_needed_value_with_locals(result, main_thread_locals).await.into_teo_path_result()?;
169169
Python::with_gil(|py| {
170170
let response: Response = awaited_result.extract(py).into_teo_path_result()?;
171171
Ok(response.teo_response.clone())
@@ -231,7 +231,7 @@ impl Namespace {
231231
let coroutine = shared_result_function.call1(py, (py_ctx, py_next)).into_teo_result()?;
232232
Ok::<PyObject, teo::prelude::Error>(coroutine.into_py(py))
233233
})?;
234-
let result = await_coroutine_if_needed_async_value(coroutine, main_thread_locals).await.into_teo_result()?;
234+
let result = await_coroutine_if_needed_value_with_locals(coroutine, main_thread_locals).await.into_teo_result()?;
235235
Python::with_gil(|py| {
236236
let response: Response = result.extract(py).into_teo_result()?;
237237
Ok(response.teo_response)

src/utils/await_coroutine_if_needed.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use pyo3::{IntoPy, PyAny, PyErr, PyObject, PyResult, Python};
22
use pyo3_asyncio::{into_future_with_locals, TaskLocals};
33
use crate::utils::is_coroutine::is_coroutine;
44

5-
pub async fn await_coroutine_if_needed_async_value(transformed_py: PyObject, main_thread_locals: &TaskLocals) -> PyResult<PyObject> {
5+
pub async fn await_coroutine_if_needed_value_with_locals(transformed_py: PyObject, main_thread_locals: &TaskLocals) -> PyResult<PyObject> {
66
let is_coroutine_bool = Python::with_gil(|py| {
77
is_coroutine(transformed_py.as_ref(py))
88
})?;
@@ -19,7 +19,7 @@ pub async fn await_coroutine_if_needed_async_value(transformed_py: PyObject, mai
1919
}
2020
}
2121

22-
pub async fn await_coroutine_if_needed_async(transformed_py: &PyAny) -> PyResult<PyObject> {
22+
pub async fn await_coroutine_if_needed(transformed_py: &PyAny) -> PyResult<PyObject> {
2323
if is_coroutine(transformed_py)? {
2424
let f = pyo3_asyncio::tokio::into_future(transformed_py)?;
2525
f.await

0 commit comments

Comments
 (0)