ipython / ipython/ipykernel

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

Aperta
#1,468 1 commento 3 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
734
Fork
412
Merge medio
1g 5h
PR unite (30g)
8

Descrizione

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.
```py
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`

* a another use case like a issue in this repo https://github.com/ipython/ipykernel/issues/391, this PR using default event loop `WindowsProactorEventLoopPolicy` can also close this issue.

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start at the Windows event-loop policy block in init() and read the referenced pull requests and issues, especially the reverted change and issue 1190. Determine the regression risk before changing the policy, then verify that Windows asyncio code using create_subprocess_exec works without the reported earlier failure.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
backend, operating-systems
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.