not real asyncio
ArtemIsmagilov opened this issue · comments
Hi, wrote simple code with asyncio modules. But your lib create new threads. on python documentation - [asyncio](https://docs.python.org/3/library/asyncio.html#module-asyncio) offers an alternative approach to achieving task level concurrency without requiring the use of multiple operating system threads.
. I think need rewrite thread based on tasks concurrency.
I note that multiplexing significantly increases speed.
thank you for continuing the legendary requests library.)
import threading
import asyncio
from time import time
import niquests
async def main():
async with niquests.AsyncSession(multiplexed=True) as s:
start_time = time()
t1 = asyncio.create_task(s.get('https://google.com/search?q=python'))
t2 = asyncio.create_task(s.get('https://google.com/search?q=python'))
await t1
await t2
end_time = time() - start_time
print(t1.result().status_code, threading.enumerate(), end_time)
asyncio.run(main())
You are right, indeed. You will be happy to know that async will be fully based on task with the next minor.
So you just have to wait a little bit longer to gain (again) a substantial boost.
I am closing this issue, feel free to subscribe to this repository to know when it happen.
Regards,
This is great news, thanks)
Update: It's live. Upgrade to latest. v3.5
Update: It's live. Upgrade to latest. v3.5
Nice work!