Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock on KeyboardInterrupt in asyncio context #88

Open
ghost opened this issue Jul 28, 2020 · 0 comments
Open

Deadlock on KeyboardInterrupt in asyncio context #88

ghost opened this issue Jul 28, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 28, 2020

The following program raises a KeyboardInterrupt from an asyncio context. It prints

MARK
MARK
MARK
raising

and then hangs. The use of the nursery here is just to demonstrate that the mark function isn't being run anymore.
I would expect the program to die with a KeyboardInterrupt Error, but it just hangs and pressing Control-C also doesn't stop the program.

import asyncio

import trio_asyncio
import trio

async def mark():
    while 1:
        print("MARK")
        await trio.sleep(1.0)

async def start():
    async def ctrlc_me():
        await asyncio.sleep(2.5)
        print("raising")
        raise KeyboardInterrupt("ctrl-c")

    async with trio.open_nursery() as nursery:
        nursery.start_soon(mark)
        try:
            await trio_asyncio.aio_as_trio(ctrlc_me)
        finally:
            print("DONE")

if __name__ == "__main__":
    trio_asyncio.run(start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants