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

Include in the samples how to write to open files like stdout #131

Closed
dougransom opened this issue Feb 19, 2022 · 0 comments · Fixed by #154
Closed

Include in the samples how to write to open files like stdout #131

dougransom opened this issue Feb 19, 2022 · 0 comments · Fixed by #154

Comments

@dougransom
Copy link

please include in the docs how to write to stdout. here is a snippent of how i did it , wrap isn't documented.

`import asyncio
from email import contentmanager
import aiohttp
import aiofiles
from aiofiles.os import wrap
import sys
import os

aio_write = aiofiles.os.wrap(os.write)

async def main():
async with aiofiles.open("sample.txt") as f:
#contents=await f.read()
write_stdout=wrap(sys.stdout.write)
print_stdout=wrap(print)

    async for contents in f:
        await write_stdout(contents)
        #await  print_stdout(f"stdout test")

asyncio.run(main())`

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

Successfully merging a pull request may close this issue.

1 participant