So I managed to get asyncio / the Google CSE API to work together.... When I run my code on PyCharm, I am able to print my results out. However, at the very end of the printed stuff is the error "TypeError: 'NoneType' object is not callable".
I suspect it has something to do with my list and maybe the loop trying to search for another term even though I'm at the end of the list...
Also.. this is my first question post so feel free to offer suggestions on how to ask questions better as well
Thoughts?
searchterms = ['cheese',
'hippos',
'whales',
'beluga']
async def sendQueries(queries, deposit=list()):
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
loop = asyncio.get_event_loop()
futures = [
loop.run_in_executor(
executor,
searching(queries)
)
]
for response in await asyncio.gather(*futures):
deposit.append(response.json())
return deposit
def running():
loop = asyncio.get_event_loop()
loop.run_until_complete(loop.create_task(sendQueries(searchterms)))
loop.close()
print(running())
print(str(time.time() - x))
My error can be traced back to "for response in await asyncio.gather(*futures):"
For your reference, searching(queries) is simply the function for my Google CSE API call.
deposit. - dirn