-
-
Save cuongld2/d1ab810c776e6ff2e5fa788c86f4dfd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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