摘要:
#asyncio 没有提供http协议的接口 aiohttp import asyncio import socket from urllib.parse import urlparse async def get_url(url): #通过socket请求html url = urlparse(url) host = url.netloc path = ur... 阅读全文
摘要:
import asyncio def callback(loop, i): print("success time {} {}".format(i, loop.time())) async def get_html(url): print("start get url") await asyncio.sleep(1) print("end get url") ... 阅读全文
摘要:
#使用多线程:在协程中集成阻塞io import asyncio from concurrent.futures import ThreadPoolExecutor import socket from urllib.parse import urlparse def get_url(url): #通过socket请求html url = urlparse(url) ... 阅读全文
摘要:
1. call_soon, 协程一运行就马上运行 2. call_later 3. call_at 阅读全文