Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

uvloop closes underlying sockets that were established outside upon end of asyncio.run()

未關閉
#464 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
python

研究方向

首先執行提供的 Unix-socket reproducer,並將 uvloop 與一般的 asyncio 迴圈進行比較。追蹤 asyncio.open_unix_connection() 和 asyncio.run() 周圍的 socket 所有權及關閉生命週期;當外部建立的 socket 在 asyncio.run() 之後仍可使用,且該回歸由測試涵蓋時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

This seem to be version/OS unrelated. Sample:

import asyncio
import socket
import uvloop

b = bytes('{"msg": "test"}', 'utf-8')


async def main_async(sock: socket.socket):
    _, writer = await asyncio.open_unix_connection(sock=sock)
    writer.write(b)
    await writer.drain()


if __name__ == '__main__':
    sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    sock.connect('data/sockets/echo_server.sock')
    sock.sendall(b)
    uvloop.install()
    asyncio.run(main_async(sock))  # sock gets wrongly closed on asyncio.run() termination
    sock.sendall(b)  # Exception here OSError: [Errno 9] Bad file descriptor

Last line result in exception "OSError: [Errno 9] Bad file descriptor" because sock gets closed right after asyncio.run() terminates. It is wrong behavior, because sock was created outside of asyncio loop and has to be left untouched. The issue doesn't occur using regular asyncio loop.

主要語言
Cython
星號
11.9k
分支
615
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

MagicStack/uvloop 的其他 Issue

查看 MagicStack/uvloop 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。