Removing `@register_integration("asyncio")` and `def loop_asyncio(kernel):`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
Hướng nghiên cứu
Bắt đầu với ipykernel/eventloops.py, xung quanh mã tích hợp được liên kết, và theo dõi cách mã này được gọi từ enter_eventloop() trong kernelbase.py. So sánh hành vi với các thay đổi đối với vòng lặp sự kiện asyncio được mô tả trong pull request 1469, sau đó xác minh rằng việc thực thi %gui asyncio lặp lại không còn khiến số lượng tác vụ asyncio tăng lên hoặc làm lãng phí CPU.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In current versions of ipykernel, when you execute in jupyter, vscode jupyter,
%gui asyncio
then after a while, when you execute
import asyncio
asyncio.all_tasks()```
you will get and see like
{<Task pending name='Task-52016' coro=<_async_in_context.<locals>.run_in_context() running at D:\test\ipykernel\ipykernel\utils.py:60> wait_for=<Task pending name='Task-52017' coro=<Kernel.shell_main() running at D:\test\ipykernel\ipykernel\kernelbase.py:621> cb=[Task.task_wakeup()]> cb=[ZMQStream._run_callback.<locals>._log_error() at e:\.pixi\envs\default\Lib\site-packages\zmq\eventloop\zmqstream.py:563]>,
<Task pending name='Task-5217' coro=<Kernel.shell_main() running at D:\test\ipykernel\ipykernel\kernelbase.py:621> cb=[Task.task_wakeup()]>}
It keeps increasing task count and it wastes your some cpu resource in the background. It's acually running these below codes, it just enters the function the return repeatedly, by self.io_loop.call_later(0.001, advance_eventloop) of enter_eventloop() in kernelbase.py.
https://github.com/ipython/ipykernel/blob/8816d024bf730e9fdb051b44ab2fc1ee2276cea2/ipykernel/eventloops.py#L430-L473
How it happened:
The @register_integration("asyncio") and def loop_asyncio(kernel): was at the old ages, to drive the asyncio codes that inputed by users, like asyncio.ensure_future(...), when ipykernel was running under IOloop of tornado<6.1 which using the selectorloop or even older type eventloop. It was to make users able to run asyncio codes when the underhood is other things.
The current ipykernel its main loop is already asyncio loop, by IOloop of tornado>6.1. The user inputed asyncio codes already run in the main loop.
Therefore the related codes @register_integration("asyncio") and def loop_asyncio(kernel): could be deleted.
Solution:
related issue: https://github.com/ipython/ipykernel/pull/1469 solving the proactor and selector eventloop within asyncio
- Ngôn ngữ chính
- Python
- Star
- 734
- Fork
- 411
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 8
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ipython/ipykernel
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
-
ipython/ipykernel#1550 · 1 bình luận · 1 reaction · 1 người được giao ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của ipython/ipykernel
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100