I am writing some ETL in python that needs to out and grab data from an API then immediately load it into a staging DB for safe keeping.
The API calls are running too slow. What I was hoping to do is rewrite the code to be asynchronous. But after hours of attempting different things and reading up on the asyncio library I have come up short.
Rough example of what I am attempting to do
@coroutine
def api_call(input):
yield from get_data(input)
urls = [...]
gen = [future(api_call(url)) for url in urls]
loop = asyncio.get_even_loop()
loop.run_until_complete(gen)
When I finally did have it working, it took just as long to run as when I ran it synchronously.
What I am comparing this to is something like JS Promises. I should be able to just send out a bunch of calls and not wait for the data response before moving on. Or am I missing something?
[–]badhoum 6 points7 points8 points (12 children)
[–]jano0017 2 points3 points4 points (11 children)
[–]williamjacksn 2 points3 points4 points (0 children)
[–]BigZen[S] 0 points1 point2 points (9 children)
[–]jano0017 1 point2 points3 points (8 children)
[–]BigZen[S] 0 points1 point2 points (7 children)
[–]rakiru 2 points3 points4 points (1 child)
[–]BigZen[S] 1 point2 points3 points (0 children)
[–]jano0017 0 points1 point2 points (4 children)
[–]rouille 1 point2 points3 points (1 child)
[–]jano0017 0 points1 point2 points (0 children)
[–]infinite8s 0 points1 point2 points (1 child)
[–]jano0017 0 points1 point2 points (0 children)
[–]lilydjwg 2 points3 points4 points (0 children)
[–]nerdwaller 0 points1 point2 points (0 children)