[issue43528] "connect_read_pipe" raises errors on Windows for STDIN

2022-04-07 Thread Kumar Aditya


Change by Kumar Aditya :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> ProactorEventLoop doesn't support stdin/stdout nor files with 
connect_read_pipe/connect_write_pipe

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43528] "connect_read_pipe" raises errors on Windows for STDIN

2021-03-17 Thread Ivan Kravets


New submission from Ivan Kravets :

Hi there,

It seems that "connect_read_pipe" is not implemented in ProactorEventLoop. Does 
it make sense to update docs in these places?
- https://docs.python.org/3/library/asyncio-platforms.html#windows
- https://docs.python.org/3/library/asyncio-eventloop.html#working-with-pipes 

Or, this is a bug?

# The code to reproduce

```
import asyncio
import sys


async def read_stdin():
reader = asyncio.StreamReader()
protocol = asyncio.StreamReaderProtocol(reader)
await asyncio.get_running_loop().connect_read_pipe(lambda: protocol, 
sys.stdin)
while True:
line = await reader.readline()
print("stdin > ", line)


async def main():
task = asyncio.create_task(read_stdin())
await asyncio.sleep(5)
task.cancel()


if __name__ == "__main__":
asyncio.run(main())
```

P.S: The "loop.add_reader()" raises "NotImplementedError" which is clear 
according to the docs.

Thanks in advance!

# Log

```
C:\Users\USER>.platformio\python3\python.exe test.py
Exception in callback _ProactorReadPipeTransport._loop_reading()
handle: 
Traceback (most recent call last):
  File "C:\Users\USER\.platformio\python3\lib\asyncio\proactor_events.py", line 
299, in _loop_reading
self._read_fut = self._loop._proactor.recv(self._sock, 32768)
  File "C:\Users\USER\.platformio\python3\lib\asyncio\windows_events.py", line 
445, in recv
self._register_with_iocp(conn)
  File "C:\Users\USER\.platformio\python3\lib\asyncio\windows_events.py", line 
718, in _register_with_iocp
_overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0)
OSError: [WinError 6] The handle is invalid

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\USER\.platformio\python3\lib\asyncio\events.py", line 80, in 
_run
self._context.run(self._callback, *self._args)
  File "C:\Users\USER\.platformio\python3\lib\asyncio\proactor_events.py", line 
309, in _loop_reading
self._fatal_error(exc, 'Fatal read error on pipe transport')
  File "C:\Users\USER\.platformio\python3\lib\asyncio\proactor_events.py", line 
131, in _fatal_error
self._force_close(exc)
  File "C:\Users\USER\.platformio\python3\lib\asyncio\proactor_events.py", line 
134, in _force_close
if self._empty_waiter is not None and not self._empty_waiter.done():
AttributeError: '_ProactorReadPipeTransport' object has no attribute 
'_empty_waiter'
Exception ignored in: 
Traceback (most recent call last):
  File "C:\Users\USER\.platformio\python3\lib\asyncio\proactor_events.py", line 
116, in __del__
self.close()
  File "C:\Users\USER\.platformio\python3\lib\asyncio\proactor_events.py", line 
108, in close
self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\USER\.platformio\python3\lib\asyncio\base_events.py", line 
746, in call_soon
self._check_closed()
  File "C:\Users\USER\.platformio\python3\lib\asyncio\base_events.py", line 
510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
```

--
components: asyncio
messages: 388919
nosy: asvetlov, ivankravets, yselivanov
priority: normal
severity: normal
status: open
title: "connect_read_pipe" raises errors on Windows for STDIN
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com