Skip to content
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

The S3 file like writer in Python is not completing correctly. #4120

Closed
zzl221000 opened this issue Feb 1, 2024 · 8 comments · Fixed by #4122
Closed

The S3 file like writer in Python is not completing correctly. #4120

zzl221000 opened this issue Feb 1, 2024 · 8 comments · Fixed by #4122
Labels
bindings/python bug Something isn't working good first issue Good for newcomers

Comments

@zzl221000
Copy link
Contributor

The code is as follows.

import opendal

op = opendal.Operator('oss',...)
f = op.open('file.txt', 'wb')
f.write(b'0' * 1024 * 1024)
f.close()

Created a Multipart, but the close method did not complete the Multipart.

@Xuanwo
Copy link
Member

Xuanwo commented Feb 1, 2024

Hi, would like to share more details about this? Did it raise an error?

@zzl221000
Copy link
Contributor Author

Hi, would like to share more details about this? Did it raise an error?

@Xuanwo The program ends without any exceptions.

Process finished with exit code 0

Moreover, when the write method is called only once, not even a Multipart is created; it just writes to the memory.

@Xuanwo
Copy link
Member

Xuanwo commented Feb 1, 2024

Moreover, when the write method is called only once, not even a Multipart is created; it just writes to the memory.

First, if the write function is only called once, we will optimize it by avoiding multipart upload to minimize API calls. Additionally, opendal requires calling close to ensure that all data has been flushed.

@zzl221000
Copy link
Contributor Author

@Xuanwo
I called the close method. f.close()

@Xuanwo
Copy link
Member

Xuanwo commented Feb 1, 2024

Ok, I got it. It does a bug in our opendal binding. We missed to call close for the file internally.

@Xuanwo Xuanwo added bindings/python bug Something isn't working good first issue Good for newcomers labels Feb 1, 2024
@Xuanwo
Copy link
Member

Xuanwo commented Feb 1, 2024

We can fix it by calling close in inner.close() and __exit__. @zzl221000 would you like to help fix this?

@zzl221000
Copy link
Contributor Author

@Xuanwo I tried to fix it, but my autoformatter had some issues, leading to additional commits.

@Xuanwo
Copy link
Member

Xuanwo commented Feb 1, 2024

@Xuanwo I tried to fix it, but my autoformatter had some issues, leading to additional commits.

Thanks!

Xuanwo pushed a commit that referenced this issue Feb 1, 2024
…4122)

* fix(bindings/python): missed to call close for the file internally (#4120)

* style: cargo fmt

* style: clippy check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings/python bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants