awacke1 commited on
Commit
c36fabe
·
1 Parent(s): bee76fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -20,9 +20,11 @@ async def scrape_wikipedia(url):
20
 
21
  async def scrape_urls(urls):
22
  tasks = []
 
 
23
  async with concurrent.futures.ThreadPoolExecutor(max_workers=len(urls)) as executor:
24
  for url in urls:
25
- tasks.append(asyncio.ensure_future(scrape_wikipedia(url)))
26
  await asyncio.gather(*tasks)
27
  return tasks
28
 
 
20
 
21
  async def scrape_urls(urls):
22
  tasks = []
23
+ loop = asyncio.new_event_loop()
24
+ asyncio.set_event_loop(loop)
25
  async with concurrent.futures.ThreadPoolExecutor(max_workers=len(urls)) as executor:
26
  for url in urls:
27
+ tasks.append(loop.run_in_executor(executor, scrape_wikipedia, url))
28
  await asyncio.gather(*tasks)
29
  return tasks
30