-
Notifications
You must be signed in to change notification settings - Fork 22
Move Python::attach calls outside of tokio event loop in future_into_py #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,13 @@ impl GenericRuntime for TokioRuntime { | |
fut.await; | ||
}) | ||
} | ||
|
||
fn spawn_blocking<F>(f: F) -> Self::JoinHandle | ||
where | ||
F: FnOnce() + Send + 'static, | ||
{ | ||
get_runtime().spawn_blocking(f) | ||
} | ||
} | ||
|
||
impl ContextExt for TokioRuntime { | ||
|
@@ -318,7 +325,7 @@ pub fn future_into_py_with_locals<F, T>( | |
) -> PyResult<Bound<PyAny>> | ||
where | ||
F: Future<Output = PyResult<T>> + Send + 'static, | ||
T: for<'py> IntoPyObject<'py>, | ||
T: for<'py> IntoPyObject<'py> + Send + 'static, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change, right? Should we highlight that in the Changelog? What if someone wants to use this with a non- There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Practically it is uncommon to have a future which is However, generic code (like generic wrappers of |
||
{ | ||
generic::future_into_py_with_locals::<TokioRuntime, F, T>(py, locals, fut) | ||
} | ||
|
@@ -364,7 +371,7 @@ where | |
pub fn future_into_py<F, T>(py: Python, fut: F) -> PyResult<Bound<PyAny>> | ||
where | ||
F: Future<Output = PyResult<T>> + Send + 'static, | ||
T: for<'py> IntoPyObject<'py>, | ||
T: for<'py> IntoPyObject<'py> + Send + 'static, | ||
{ | ||
generic::future_into_py::<TokioRuntime, _, T>(py, fut) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda hard to tell from the diff, but the only change here is the addition of
spawn_blocking
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There is "hide whitespace" option in GitHub diff viewer.