Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

interrupt issues with async code

Ouverte
#1,239 4 commentaires 0 réactions 1 personne assignée Voir sur GitHub

@Carreau y travaille déjà.

Depuis le 26/8/2026.

Évaluation

Cette issue n'a pas encore été évaluée.

Description

bug

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.

Langage dominant
Python
Étoiles
734
Forks
411
Merge moyen
1 j 2 h
PR mergées (30 j)
9

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de ipython/ipykernel

Toutes les issues de ipython/ipykernel

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.