Skip to content

Support for async clients #17

@d1618033

Description

@d1618033

Is there support for async clients (like aiohttp)?

I'm running the following code, and the sync version is working fine, but the async version is timing out.

import asyncio

import aiohttp
import flask
import requests
from flask_loopback import FlaskLoopback

app = flask.Flask(__name__)
@app.route("/")
def index():
    return "index"


async def async_client():
    async with aiohttp.ClientSession() as client:
        async with client.get("http://mock/") as response:
            print("async_client", await response.text())


def sync_client():
    print("sync_client", requests.get("http://mock/").text)


with FlaskLoopback(app).on(("mock", 80)):
    sync_client()
    asyncio.run(async_client())

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