MagicStack / MagicStack/uvloop
Tests trying to find unused ports are flakey when automated
还没有人认领这个 Issue。
- 主要语言
- Cython
- 星标
- 11.9k
- 派生
- 615
- PR 合并指标
- 30 天内没有已合并 PR
描述
- uvloop version: 0.17.0
- Python version: 3.10
- Platform: nix/darwin
- Can you reproduce the bug with
PYTHONASYNCIODEBUGin env?: N/A - Does uvloop behave differently from vanilla asyncio? How?: N/A
The tests using find_free_port (like https://github.com/MagicStack/uvloop/blob/d2deffefa18653636eb03ea77a5dab6e4febf6c6/tests/test_tcp.py#L252) may fail in busy CI environments. For example building for nixpkgs involves running tests every time. It ends up with: (https://hydra.nixos.org/build/197525892/nixlog/1)
=================================== FAILURES ===================================
_______________________ Test_UV_TCP.test_create_server_5 _______________________
Traceback (most recent call last):
File "/private/tmp/tmp.xkcj6kx4o4/tests/test_tcp.py", line 245, in test_create_server_5
self.loop.run_until_complete(runner())
File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
File "/private/tmp/tmp.xkcj6kx4o4/tests/test_tcp.py", line 238, in runner
srv = await self.loop.create_server(
File "uvloop/loop.pyx", line 1790, in create_server
OSError: [Errno 48] error while attempting to bind on address ('::', 50000, 0, 0): address already in use
_______________________ Test_UV_TCP.test_create_server_6 _______________________
Traceback (most recent call last):
File "/private/tmp/tmp.xkcj6kx4o4/tests/test_tcp.py", line 271, in test_create_server_6
self.loop.run_until_complete(runner())
File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
File "/private/tmp/tmp.xkcj6kx4o4/tests/test_tcp.py", line 255, in runner
srv1 = await self.loop.create_server(
File "uvloop/loop.pyx", line 1790, in create_server
OSError: [Errno 48] error while attempting to bind on address ('::', 50000, 0, 0): address already in use
=============================== warnings summary ===============================
Do those tests need to use a common ipv4/6 socket? Could they use only one protocol at a time with port 0 and then get the local port number from the result?
Or maybe build the retry loop around the first socket creation rather than 2 independent steps?
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 tests/test_tcp.py 开始,尤其关注 test_create_server_5 和 test_create_server_6 附近使用 find_free_port 的测试。在自动化或繁忙的环境中重现这些失败,然后评估使用端口 0、共享的 IPv4/IPv6 套接字,或重试创建第一个套接字。完成的标准是:测试不再因为所选端口已被占用而失败。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- networking, testing
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100