При первоначальном обнаружении я решил перестроить функцию, поскольку именно я ее построил, так что, возможно, я просто сделал что-то не так:
Код: Выделить всё
async def main():
industry = 'resturaunts'
async with aiohttp.ClientSession() as session:
next_page_token = None
companies = await process_industry(industry, session, next_page_token)
for company in companies:
await outreach_to_company(session, company,10)
Код: Выделить всё
async def main():
await send_email("tgjadore@gmail.com", 'Company')
Код: Выделить всё
async def main():
industries = ['restaurants', 'barbers', 'cafes', 'gyms']
async with aiohttp.ClientSession() as session:
for industry in industries:
next_page_token = None
while True:
companies = get_companies(industry, next_page_token)
if not companies or 'places' not in companies:
print('Nothing to scrape')
break
tasks = [outreach_to_company(session, company) for company in companies['places']]
print(tasks)
await asyncio.gather(*tasks)
if 'nextPageToken' not in companies:
print('No nextPageToken')
break
next_page_token = companies['nextPageToken']
await asyncio.sleep(10)
Вот полный скрипт на случай, если он чем-нибудь поможет (mail.py): https://github.com/JadoreThompson/Email ... evelopment
Подробнее здесь: https://stackoverflow.com/questions/787 ... thon-async