You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have written a code that works on asyncio. In that code, I had to read a file from standard input using ./check.py < file.txt I am able to give input from the terminal. normally it works fine. But it doesn't work for reading data from a file from standard input.
#!/usr/bin/env python3.6
import asyncio
from aioconsole import ainput
async def read_input():
while True:
inp = await ainput()
print('got ' + inp)
if (__name__ == "__main__"):
asyncio.get_event_loop().run_until_complete(read_input())
normally it works like
$ ./check.py
4
got 4
5
got 5
But while reading from file directly I face this log:
$ ./check.py < test/test_case
Traceback (most recent call last):
File "./check.py", line 12, in <module>
asyncio.get_event_loop().run_until_complete(read_input())
File "/usr/lib/python3.6/asyncio/base_events.py", line 468, in run_until_complete
return future.result()
File "./check.py", line 8, in read_input
inp = await ainput()
File "/usr/local/lib/python3.6/dist-packages/aioconsole/stream.py", line 156, in ainput
reader, writer = yield from get_standard_streams(loop=loop)
File "/usr/local/lib/python3.6/dist-packages/aioconsole/stream.py", line 144, in get_standard_streams
cache[key] = yield from connection
File "/usr/local/lib/python3.6/dist-packages/aioconsole/stream.py", line 132, in create_standard_streams
reader, writer = yield from future
File "/usr/local/lib/python3.6/dist-packages/aioconsole/stream.py", line 114, in open_pipe_connection
yield from loop.connect_read_pipe(lambda: protocol, pipe_in)
File "/usr/lib/python3.6/asyncio/base_events.py", line 1099, in connect_read_pipe
transport = self._make_read_pipe_transport(pipe, protocol, waiter)
File "/usr/lib/python3.6/asyncio/unix_events.py", line 185, in _make_read_pipe_transport
return _UnixReadPipeTransport(self, pipe, protocol, waiter, extra)
File "/usr/lib/python3.6/asyncio/unix_events.py", line 353, in __init__
raise ValueError("Pipe transport is for pipes/sockets only.")
ValueError: Pipe transport is for pipes/sockets only.
Unable to get why is it behaving differently? I want to read a file like ./check.py < file.txt using coroutines.
Thanks in advance :)
Regards,
Sarbjit Singh
The text was updated successfully, but these errors were encountered:
It turns out this issue has already been fixed in PR #25. It became visible in version 0.1.9 that I just released. Run pip3 install -U aioconsole and you should be good to go :)
I have written a code that works on asyncio. In that code, I had to read a file from standard input using
./check.py < file.txt
I am able to give input from the terminal. normally it works fine. But it doesn't work for reading data from a file from standard input.normally it works like
But while reading from file directly I face this log:
Unable to get why is it behaving differently? I want to read a file like ./check.py < file.txt using coroutines.
Thanks in advance :)
Regards,
Sarbjit Singh
The text was updated successfully, but these errors were encountered: