Skip to content

Instantly share code, notes, and snippets.

@cuongld2
Created Aug 27, 2021
Embed
What would you like to do?
import pytest
import httpx
import asyncio
import time
@pytest.mark.asyncio
async def test_without_await():
start_time = time.time()
loop = asyncio.get_event_loop()
async with httpx.AsyncClient() as client:
r_github=loop.create_task(client.get('https://api.github.com/orgs/octokit/repos'))
r_dev = loop.create_task(client.get('https://dev.to/api/articles/latest'))
await asyncio.sleep(2)
await r_github
await r_dev
assert r_github.result().status_code == 200
assert len(r_dev.result().json()) == 30
finish_time=time.time()
print(finish_time-start_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment