AttributeError: Modul 'select' hat kein Attribut 'SELECT' Fehler asyncioPython

Python-Programme
Anonymous
 AttributeError: Modul 'select' hat kein Attribut 'SELECT' Fehler asyncio

Post by Anonymous »

Ich mache den folgenden Code auf einem Windows -PC. Ich habe gelesen, dass Windows standardmäßig nur 64 Sockets in der Asyncio -Schleife verwenden kann. Ich weiß nicht, ob dies der Grund für den Fehler ist. < /P>

Code: Select all

import aiohttp
import asyncio
import time

async def download_file(url):
print(f'started downloading{url}')
connector = aiohttp.TCPConnector(limit=60)
async with aiohttp.clientSession(connector) as session:
async with session.get(url) as resp:
content = await  resp.read()
print (f'Finished download{url}')
return content

async def write_file(n, content):
filename = f'async_{n}.html'
with open(filename,'wb') as f:
print(f'started writing{filename}')
f.write(content)
print(f'Finished writing{filename}')

async def scrape_task(n,url):
content = await download_file(url)
await write_file(n,content)

async def main():
tasks = []
for n,url in enumerate(open('urls.txt').readlines()):
tasks.append((scrape_task(n, url)))
await asyncio.wait(tasks)

if __name__ == '__main__':
t=time.perf_counter()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
t2 = time.perf_counter() - t
print(f'Total time taken: {t2:0.2f} seconds')
Ich habe die folgenden Änderungen vorgenommen, um die Verbindungen auf 60
zu beschränken

Code: Select all

connector = aiohttp.TCPConnector(limit=60)
async with aiohttp.clientSession(connector) as session:
Ich kann nicht herausfinden, wo ich falsch gehe.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post