Closed caner-cetin closed 1 year ago
If I couldnt pinpoint the problem, there is certainly a problem in SDK that file is closed or a operation is done that file is no longer seekable.
minio-py
doesn't use httpx
instead uses urllib3
.
@balamurugana So if I use your SDK in a REST API endpoint, I can't ping it with HTTPx anymore for testing? Wow.
Maybe you can write this in a small corner of documentation, as this may be annoying to some like I find it.
And urllib3 does not support async client. So uh, flexibility would be nice.
THIS IS NOT JUST HTTPx, ANY OPERATIONS ON FILES LIKE SEEK ON FILE AFTER THE MinIO SDK OPERATIONS WILL BREAK.
Title.
https://github.com/minio/minio-py/blob/master/minio/api.py#L941
Do you see the
code block? Yes, it completely breaks HTTPx client requests. How?
https://github.com/encode/httpx/blob/master/httpx/_client.py#L1584
Do you see the
code block? I get
error when I do
How? Now look at https://github.com/minio/minio-py/blob/master/minio/api.py#L941 again. Whenever I ping against an FastAPI endpoint that uses MinIO SDK, MinIO SDK will do the operations, and CLOSE the file after it is done thanks to:
and due to MinIO SDK closing the file before the endpoint's purpose is over, when we get the response, file will be closed, and when HTTPx is assembling the response it will try to seek the file for some reason, and shit will happen.
Example code:
where object.file.fileno is => https://docs.python.org/3.10/library/tempfile.html#tempfile.SpooledTemporaryFile.fileno
I dont know who to blame for this, but yeah.