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

Missing feature: sendfile #45

Open
njsmith opened this issue Feb 11, 2017 · 4 comments
Open

Missing feature: sendfile #45

njsmith opened this issue Feb 11, 2017 · 4 comments

Comments

@njsmith
Copy link
Member

@njsmith njsmith commented Feb 11, 2017

On Unix, os.sendfile is present and just needs a simple (but slightly finicky) wrapper.

On Windows, os.sendfile doesn't exist, but we can wrap TransmitFile - shouldn't be too hard.

@njsmith
Copy link
Member Author

@njsmith njsmith commented Jan 19, 2018

Asyncio support is coming in 3.7: https://bugs.python.org/issue32410

@sseg
Copy link

@sseg sseg commented Apr 14, 2018

I started having a look at this but I'm not sure how you intend the API. Do you think that trio.socket.sendfile should accept AsyncIOWrapper, plain file objects, or both?

@njsmith
Copy link
Member Author

@njsmith njsmith commented Apr 14, 2018

Oh shoot, that's an excellent question. I was just thinking about wrapping sendfile in the obvious naive way, like we wrap send or whatever, but I forgot that this may cause synchronous disk access. And it's a bit tricky, because we could route it through a thread like we do with other disk access, but in this case that might add enough overhead to defeat the purpose of using sendfile in the first place. It's also unclear whether a thread is really necessary on Windows – maybe TransmitFile does async disk I/o natively?

It would help to have more information. I guess one way forward would be to start by making a toy little benchmark that uses sendfile in the naive way on Linux, and compare it to read+send, to see what benefit we can even hope to get?

@njsmith njsmith mentioned this issue Sep 26, 2018
0 of 11 tasks complete
@pipehappy1
Copy link

@pipehappy1 pipehappy1 commented Jan 17, 2020

Do we have any update on this? Having sendfile in the API would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants