ipykernel should use default `WindowsProactorEventLoopPolicy` rather than `WindowsSelectorEventLoopPolicy` for windows

未关闭
#1,468 1 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python

调研方向

从 init() 中的 Windows 事件循环策略代码块开始,阅读所引用的 pull request 和 issue,尤其是已回滚的更改和 issue 1190。在更改策略之前确定回归风险,然后验证使用 create_subprocess_exec 的 Windows asyncio 代码能够正常工作,不会出现之前报告的故障。

由索引模型根据 Issue 内容生成。

描述

there were some issues discussed about this problem before https://github.com/ipython/ipykernel/pull/1184,
then https://github.com/ipython/ipykernel/issues/1190 caused https://github.com/ipython/ipykernel/pull/1194 reverted the above PR.
I tried the https://github.com/ipython/ipykernel/issues/1190 but it's unable to reproduce now in ipykernel version 7.1.

the asyncio on windows needs WindowsProactorEventLoopPolicy to have the ability to use create_subprocess_exec, which is used in practice places, for example:

  • using playwright which is a new automation tools after selenium.
import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        await page.goto("https://playwright.dev")
        print(await page.title())
        await browser.close()

await main()
# asyncio.run(main())

         on windows, the above codes is not useable in ipython, junpyter, or jupyter notebook in vscode because of WindowsSelectorEventLoopPolicy lacking of create_subprocess_exec

Even If the above https://github.com/ipython/ipykernel/issues/1190 is still reproduceable, then should fix it, to make asyncio create_subprocess_exec is working on windows in jupyter.

therefore I created a PR again to get rid of using WindowsSelectorEventLoopPolicy on windows, since https://github.com/ipython/ipykernel/releases/tag/v7.0.0 dropped support for python 3.9, so the PR is simply removing the whole block code of the init() that checked python version

ps.
there is a old issue before https://github.com/ipython/ipykernel/pull/1184 which talked about that tornado 6.1 used background threads and which may reduce performance, but result of running test in https://github.com/ipython/ipykernel/pull/1184 showed performance improved rather than reduced. and that asyncio on windows has ability to use a common api create_subprocess_exec should be more important than threads in background problem

主要语言
Python
星标
734
派生
411
平均合并
1 天 2 小时
30 天内合并 PR
9

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ipython/ipykernel 的其他 Issue

查看 ipython/ipykernel 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。