Skip to content

Add AsyncIO backend - #155

Draft
cgl wants to merge 1 commit into
mainfrom
feat/asyncio-backend
Draft

cgl wants to merge 1 commit into
mainfrom
feat/asyncio-backend

Conversation

@cgl

@cgl cgl commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator
import asyncio
from hip.backends.asyncio import AsyncioBackend

async def send_hello(stream):
    await stream.write(b"hello")

async def main():
    backend = AsyncioBackend()

    async with backend.serve("127.0.0.1", 0, send_hello) as server:
        stream = await backend.connect(server.host, server.port)

        async with stream:
            assert await stream.read() == b"hello"
        assert "CLOSED" in repr(stream)

asyncio.run(main())

#138

@cgl
cgl force-pushed the feat/asyncio-backend branch from 36c17cc to dfd119c Compare November 26, 2026 11:56
@lovelydinosaur

Copy link
Copy Markdown
Member

backend.serve("127.0.0.1", 0, send_hello)

Oh, good reminder that we haven't really got the serve interface right, right?

Eg. I already know what this is gonna do... backend.serve(send_hello).
There's some obvious default args in there, and there's the handler that is mandatory.

@lovelydinosaur lovelydinosaur changed the title Add Asyncio backend Add AsyncIO backend Nov 26, 2026
__all__ = ["AsyncioBackend", "AsyncioServer", "AsyncioStream"]


class AsyncioStream(AsyncNetworkStream):

@lovelydinosaur lovelydinosaur Nov 26, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IO in caps (?)

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants