Skip to content

Doubt in spinner_async.py example #37

Open
@CarMoreno

Description

@CarMoreno

Hi Luciano,

I am playing a bit with the spinner_async.py example, and I am wondering why the execution finishes normally when I comment the spinner.cancel() line in the supervisor function. I think the execution should stay in an infinite loop because I am not cancelling the coroutine and, therefore the asyncio.CancelledError exception is never raised.

async def supervisor() -> int:  # <3>
    spinner = asyncio.create_task(spin('thinking!'))  # <4>
    print(f'spinner object: {spinner}')  # <5>
    result = await slow()  # <6>
    #spinner.cancel()  # <------This is the only change <7>
    return result

I am forgetting something?, any comments to help me to understand this scenario are welcome.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions