interrupt issues with async code
@Carreau がすでに取り組んでいます。
2026年8月26日 から。
評価
この issue はまだ評価されていません。
説明
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.
- 主要言語
- Python
- スター
- 734
- フォーク
- 411
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 9
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ipython/ipykernel のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 66/100
ipython/ipykernel の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
learningequality/ricecooker#747 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
run-llama/llama_index#23199 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
KhronosGroup/glTF-Blender-IO#2769 ·