MagicStack / MagicStack/uvloop

Repeating calls to connect_write_pipe with sys.stdout as a stream lead to FileExistsError exception

Open
#262 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted need more info
Dominant language
Cython
Stars
11.9k
Forks
616
PR merge metrics
No merged PRs in 30d

Description

* **uvloop version**: 0.11.3, 0.12.2, 0.13.0rc1
* **Python version**: 3.6, 3.7
* **Platform**: linux, macos
* **Can you reproduce the bug with `PYTHONASYNCIODEBUG` in env?**: yes

Hello, this example doesn't work with uvloop.
```python
import asyncio
import sys
import uvloop

uvloop.install()
loop = asyncio.get_event_loop()

async def main():
transport, protocol = await loop.connect_write_pipe(
asyncio.Protocol, sys.stdout
)
print("okay")

transport2, protocol2 = await loop.connect_write_pipe(
asyncio.Protocol, sys.stdout
)
print("okay")

loop.run_until_complete(main())
```

```
okay
Traceback (most recent call last):
File "uvl.py", line 20, in
loop.run_until_complete(main())
File "uvloop/loop.pyx", line 1451, in uvloop.loop.Loop.run_until_complete
File "uvl.py", line 16, in main
asyncio.Protocol, sys.stdout
File "uvloop/loop.pyx", line 2703, in connect_write_pipe
File "uvloop/loop.pyx", line 2698, in uvloop.loop.Loop.connect_write_pipe
File "uvloop/handles/pipe.pyx", line 170, in uvloop.loop.WriteUnixTransport._open
File "uvloop/handles/pipe.pyx", line 29, in uvloop.loop.__pipe_open
FileExistsError: [Errno 17] File exists
```

please, see discussion here https://github.com/B2W-BIT/aiologger/issues/42#issuecomment-457283504

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example using repeated loop.connect_write_pipe calls with sys.stdout, then inspect the stack-trace entry points in uvloop/loop.pyx and uvloop/handles/pipe.pyx. Compare the first and second pipe-opening paths and add regression coverage; done means the repeated calls complete without FileExistsError on the reported platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.