Closed VinceBackpack closed 6 years ago
That code when given real urls does not run. You need to pass the session (s) and path correctly:
import asks
import trio
asks.init(trio)
path_list = ['http://httpbin.org/get']
results = []
async def worker(s, path):
r = await s.get(path)
results.append(r)
async def main(path_list):
from asks.sessions import Session
s = Session('https://example.org' , connections=2)
async with trio.open_nursery() as n:
for path in path_list:
n.start_soon(worker, s, path)
s = asks.Session()
trio.run(main, path_list)
Last thing I promise. Replace the url with the fake urls, but everything else is good.
We don't want someone to grab this code, do for path in path_list * 1000:
and annoy httpbin.org with 1k pointless requests :D
Will do! Thanks for the helpful feedbacks btw.
good stuff ty
Updated trio example in readme for issue #87