Skip to content

Instantly share code, notes, and snippets.

@cuongld2
Created August 27, 2021 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuongld2/d1ab810c776e6ff2e5fa788c86f4dfd8 to your computer and use it in GitHub Desktop.
Save cuongld2/d1ab810c776e6ff2e5fa788c86f4dfd8 to your computer and use it in GitHub Desktop.
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