interrupt issues with async code
@Carreau đang làm issue này rồi.
Từ ngày 26/8/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Hi,
Aside from the now fixed #881, I still run into some async + interrupt issues. I'm not 100% sure if I need to do something differently or there is a way to do what we mean.
The following is not interrupted and always run to completion. If you sleep instead of httpx.get (or request.get), it works as expected.
import asyncio
import httpx
from tqdm.asyncio import tqdm as tqdm_async
semaphore = asyncio.Semaphore(1)
x = 0
async def one_at_a_time():
global semaphore
async with semaphore:
global x
# await asyncio.sleep(1)
httpx.get('http://httpbin.org/delay/1')
x += 1
print(x)
return x
await tqdm_async.gather(*[one_at_a_time() for _ in range(10)])
Ideally, I want these to be tasks so I can cancel them. Again, interrupt has no effect:
import asyncio
from time import sleep
from tqdm.asyncio import tqdm as tqdm_async
semaphore = asyncio.Semaphore(1)
x = 0
async def one_at_a_time():
global semaphore
async with semaphore:
global x
sleep(1)
x += 1
print(x)
return x
async def outer_async():
return await one_at_a_time()
await tqdm_async.gather(*[asyncio.create_task(one_at_a_time()) for _ in range(10)])
Any suggestions for how to fix my code to work better with ipykernel or how to fix ipykernel (or IPython) itself? Even better would be something that works on 6.x, but I think that may be challenging as even #881 is not fixed there.
- Ngôn ngữ chính
- Python
- Star
- 734
- Fork
- 411
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 9
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ó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ 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 48/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 ·
Tất cả issue của ipython/ipykernel
Issue tương tự
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
canonical/paas-charm#368 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
tech debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
addition to tracking list Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
StevenBlack/hosts#3256 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
qualcomm/qai-appbuilder#275 ·