We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Currently the print function doesn't work well with async code. see at https://gist.github.com/nathan-hoad/8966377#gistcomment-1222842
If you feed a few hundred bytes into print function, you will see BlockingIOError.
It is very easy to solve this problem in aioconsole IMO
A sample code could be:
from aioconsole.stream import get_standard_streams async def aprint(string): _, writer = get_standard_streams() writer.write(string.encode('utf-8')) writer.write('\n'.encode('utf-8')) await writer.drain()
Perhaps provide a shortcut for aprint might be easy for developers since we have ainput in the package.
aprint
ainput
The text was updated successfully, but these errors were encountered:
Hi @RyanWangGit and thanks for your report!
For the reference, the issue can be reproduced with the following code:
import asyncio from aioconsole import get_standard_streams async def main(): _, writer = await get_standard_streams() print('a'*64*1024) # print('a'*64*1024, file=writer) # print('OK', file=writer) # await writer.drain() if __name__ == '__main__': asyncio.run(main())
It produces the following error:
Traceback (most recent call last): File "test.py", line 12, in <module> asyncio.run(main()) File "/home/vimiche/miniconda/lib/python3.7/asyncio/runners.py", line 43, in run return loop.run_until_complete(main) File "/home/vimiche/miniconda/lib/python3.7/asyncio/base_events.py", line 568, in run_until_complete return future.result() File "test.py", line 6, in main print('a'*64*1024) BlockingIOError: [Errno 11] write could not complete without blocking
While investigating this, I also realized there was an issue with the handling of linux pipes (see #32).
Sounds good!
Sorry, something went wrong.
Add aprint coroutine (PR #34, issue #31)
2a97b92
No branches or pull requests
Currently the print function doesn't work well with async code. see at https://gist.github.com/nathan-hoad/8966377#gistcomment-1222842
If you feed a few hundred bytes into print function, you will see BlockingIOError.
It is very easy to solve this problem in aioconsole IMO
A sample code could be:
Perhaps provide a shortcut for
aprint
might be easy for developers since we haveainput
in the package.The text was updated successfully, but these errors were encountered: