-
Notifications
You must be signed in to change notification settings - Fork 39
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
Can't mix ainput() with input() on Unix #99
Comments
Hi @plammens and thanks for your report! We already had a similar discussion here: #90 (comment) Still, your suggestion about setting the non-blocking mode only when necessary is interesting, I'll think about it :) However and as I said in the comment mentioned above, I would advise to simply avoid using |
Thanks @vxgmichel, sorry hadn't seen #90, it's the same issue! I also wanted to add that I've found that when using await ainput()
print('a' * 10**7) # BlockingIOError So currently, if you use |
Regarding my suggestion, I realised it might lead to problems if multiple
Would that mess up the second one, which is still waiting? |
Yes it would, so the implementation would have to take care of that. Another solution would be to patch |
This is still causing havoc for us in the form of logging errors:
I understand the need for stdin to be set to non-blocking mode, but is there a way to ensure that doesn't happen to stdout? |
Discovered this isn't an issue with aioconsole. The behavior is coming from somwhere inside asyncio. The following code is enough to set stdout to non-blocking mode (note in the code there is no reference to stdout): reader = asyncio.StreamReader()
protocol = asyncio.StreamReaderProtocol(reader)
await asyncio.get_event_loop().connect_read_pipe(lambda: protocol, sys.stdin) |
On Linux, trying to use regular blocking
input()
after a call toainput()
fails withEOFError
.Minimal example:
On Ubuntu 20.04 (tested in WSL), if you run this and enter something at the first prompt (
ainput:
), then theinput()
call fails immediately withEOFError
.On the other hand, this works fine on Windows.
If the
input()
call is made beforeainput()
, then there are no problems.This seems to be due to the fact that
ainput()
sets theO_NONBLOCK
flag in stdin/stdout. Indeed, if this flag is cleared after the call toainput()
, theninput()
works fine again:Maybe this should be done automatically by
ainput
.The text was updated successfully, but these errors were encountered: