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 abacabadabacaba
Recipients abacabadabacaba, yselivanov
Date 2017-04-12.00:11:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491955884.31.0.0746508313156.issue30048@psf.upfronthosting.co.za>
In-reply-to
Content
If I run this code:

    import asyncio as a

    @a.coroutine
    def coro1():
        yield from a.ensure_future(coro2())
        print("Still here")
        yield from a.sleep(1)
        print("Still here 2")

    @a.coroutine
    def coro2():
        yield from a.sleep(1)
        res = task.cancel()
        print("Canceled task:", res)

    loop = a.get_event_loop()
    task = a.ensure_future(coro1())
    loop.run_until_complete(task)

I expect the task to stop shortly after a call to cancel(). It should surely stop when I try to sleep(). But it doesn't. On my machine this prints:

    Canceled task: True
    Still here
    Still here 2

So, cancel() returns True, but the task doesn't seem to be canceled.
History
Date User Action Args
2017-04-12 00:11:24abacabadabacabasetrecipients: + abacabadabacaba, yselivanov
2017-04-12 00:11:24abacabadabacabasetmessageid: <1491955884.31.0.0746508313156.issue30048@psf.upfronthosting.co.za>
2017-04-12 00:11:24abacabadabacabalinkissue30048 messages
2017-04-12 00:11:23abacabadabacabacreate