You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by su...@apache.org on 2024/02/01 13:41:59 UTC
(opendal) branch simplify-py-aexit created (now f1744bccf7)
This is an automated email from the ASF dual-hosted git repository.
suyanhanx pushed a change to branch simplify-py-aexit
in repository https://gitbox.apache.org/repos/asf/opendal.git
at f1744bccf7 refactor(bindings/python): simplify async writer aexit
This branch includes the following new commits:
new f1744bccf7 refactor(bindings/python): simplify async writer aexit
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(opendal) 01/01: refactor(bindings/python): simplify async writer aexit
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
suyanhanx pushed a commit to branch simplify-py-aexit
in repository https://gitbox.apache.org/repos/asf/opendal.git
commit f1744bccf7c48627f5638bf5c96c94284404fe3f
Author: suyanhanx <su...@gmail.com>
AuthorDate: Thu Feb 1 21:41:47 2024 +0800
refactor(bindings/python): simplify async writer aexit
Signed-off-by: suyanhanx <su...@gmail.com>
---
bindings/python/src/file.rs | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/bindings/python/src/file.rs b/bindings/python/src/file.rs
index 692bb4896d..552903b489 100644
--- a/bindings/python/src/file.rs
+++ b/bindings/python/src/file.rs
@@ -386,22 +386,12 @@ impl AsyncFile {
}
fn __aexit__<'a>(
- &self,
+ &'a mut self,
py: Python<'a>,
_exc_type: &'a PyAny,
_exc_value: &'a PyAny,
_traceback: &'a PyAny,
) -> PyResult<&'a PyAny> {
- let state = self.0.clone();
- future_into_py(py, async move {
- let mut state = state.lock().await;
- if let AsyncFileState::Writer(w) = &mut *state {
- w.close()
- .await
- .map_err(|err| PyIOError::new_err(err.to_string()))?;
- }
- *state = AsyncFileState::Closed;
- Ok(())
- })
+ self.close(py)
}
}