Skip to content

httpx requests cancelling outer tasks #3154

Closed Answered by tomchristie
Booplicate asked this question in Potential Issue
Discussion options

You must be logged in to vote

I can isolate this down further...

import asyncio

import httpcore


origin = httpcore.URL("http://www.example.com").origin

async def ping():
    async with httpcore.AsyncHTTPConnection(origin) as connection:
        try:
            url = "http://www.example.com"
            resp = await connection.request("GET", url)

        except Exception as e:
            print(repr(e))

        else:
            print(resp.status)

async def loop():
    while True:
        await asyncio.sleep(3)
        await ping()

async def spawn_task():
    task = asyncio.create_task(loop())
    while True:
        await asyncio.sleep(3)
        print("is cancelling: ", task.cancelling())
        print("is do…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Booplicate
Comment options

You must be logged in to vote
3 replies
@Booplicate
Comment options

@tomchristie
Comment options

@Booplicate
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants