-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
S3 file like objects - can they implement a flush method? #113
Comments
Is there an internal buffer in boto that needs to be flushed? |
I don't think so... that's not quite what I meant sorry. I'm trying to handle the situation where I'm passing the file object into a third-party library that I don't have control over. That library is calling the "flush" method. So I ordinarily I do:
vs
I.e. it would be nice if smart_open could be used as a direct replacement for |
I guess we can do that, sure. Any other methods of that sort? Can you add them all in a PR? Plus add clear motivation & comments to those no-op methods too, so someone doesn't remove them in the future by accident. |
@tmylk I have made a PR resolving this issue like you asked me to. Do review. |
This request is similar to previous #64 (comment) request to inherit or quack |
Yes - I was thinking a sensible implementation might inherit from I'll find some time to work on this and open a PR. |
@menshikh-iv This is done.
|
Hello Everyone, I see that @mpenkov 's comment shows that the f object has the 'fileno' method implemented. However, after migration to the new open function, I no longer see 'fileno' as a method for this object anymore. This is rather unfortunate as I would like to use the return value of smart_open.open() as the stdin parameter to a Popen call. But as it is not implemented it throws this error: Is there a reason the fileno operation is no longer supported? Or am I missing something? |
@peter-t-kim I'm not sure at which stage we got rid of fileno. I don't think it's a product of the change to the open function (that change happened at a different abstraction level). You can confirm this by checking on the commit in my previous comment (fbc82cc) and then:
When reading from S3, smart_open does not create any new file descriptors. The file descriptors get created by the OS when opening local files: in the case of reading from S3, we bypass that abstraction level entirely. So, I don't think it's possible to even have a file descriptor in your situation. If you want to pipe data from S3 into a subprocess, you have to do something like this. |
It would be useful if S3 file-like objects also implemented the "flush" method (which is available on local file like objects)
This would make it easier to use as a drop-in replacement for file-like objects.
This could be a no-op or could genuinely force a flush of data.
What do you think?
The text was updated successfully, but these errors were encountered: