This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gvanrossum
Recipients alex.gronholm, asvetlov, gvanrossum, iritkatriel, njs, tinchester, yselivanov
Date 2022-02-16.19:36:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645040197.39.0.407285605311.issue46771@roundup.psfhosted.org>
In-reply-to
Content
Alex, the goal here is not to replicate every Trio feature or behavior. For example I don't think that asyncio is likely to get level cancellation in 3.11, but we can certainly see if we can do something about some of the edge cases you mention, like the case of a task that is cancelled before it has started running, where you say that the task should be allowed to run until its first await.

It would be nice to have a native asyncio example that demonstrates this, so we have a concrete goal.

I am thinking it is something like this:

async def send_from_open_file(f, s):
    data = f.read()
    f.close()
    await s.send(data)

async def send_filename(filename, s):
    f = open(filename)
    t = asyncio.create_task(send_from_open_file(f, s))
    t.cancel()
    await asyncio.sleep(1)

This is an interesting edge case and I can see why you'd rather see this run until the `await s.send(data)` line. The question is, can we do that without breaking other promises implicit or explicit? (Just because the docs don't mention some behavior that doesn't mean we can change it. We have to consider what happens to actual real world code.)

I don't even know if this would be easy to change if we decided it was a good change. Thoughts? (Possibly this discussion belongs in a new issue, since it's not directly related to adding cancel scopes.)
History
Date User Action Args
2022-02-16 19:36:37gvanrossumsetrecipients: + gvanrossum, njs, asvetlov, alex.gronholm, yselivanov, tinchester, iritkatriel
2022-02-16 19:36:37gvanrossumsetmessageid: <1645040197.39.0.407285605311.issue46771@roundup.psfhosted.org>
2022-02-16 19:36:37gvanrossumlinkissue46771 messages
2022-02-16 19:36:37gvanrossumcreate