Skip to content

Curio-Asyncio Bridge (Discussion) #190

Closed
@dabeaz

Description

@dabeaz

PR #188 added some initial support for an curio-asyncio bridge. I've extended it with a different approach in which you can create a Curio stand-in for the asyncio event loop and submit coroutines to it. Like this::

from curio.bridge import AsyncioLoop
import asyncio

loop = AsyncioLoop()

# an asyncio coroutine - not curio
async def aio_coro(x, y):
         await asyncio.sleep(2)
         return x + y

# A curio coroutine - not asyncio
async def main():
        result = await loop.run_until_complete(aio_coro(2, 2))
        print(result)

run(main())

Under the covers, asyncio is running the event loop in a different thread. The event loop gets shut down automatically when the Curio kernel gets shutdown.

This issue is further discussion about this. What should curio-asyncio bridging look like in a ideal world?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions