【发布时间】:2021-03-23 06:06:28
【问题描述】:
所以我正在尝试制作一个我的世界名称狙击手,但它抛出了这个错误:
RuntimeError: Event loop stopped before Future completed.
我的代码:
import asyncio
import aiohttp
tokenlist = ['token1','token2','token3','token4','token5']
name = 'bruh'
async def send_requests():
coros = [
snipe_req(token) for token in tokenlist for x in range(3)
]
await asyncio.wait(coros)
async def snipe_req(token):
await asyncio.sleep(0)
async with aiohttp.ClientSession().put(f"https://api.minecraftservices.com/minecraft/profile/name/{name}",headers={"Authorization": "Bearer " + token,"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0","Content-Type": "application/json"}) as response:
await response.read()
print(response)
asyncio.get_event_loop().stop()
def run():
loop = asyncio.get_event_loop()
loop.run_until_complete(send_requests())
run()
有人知道问题出在哪里吗?
【问题讨论】:
-
为什么是
asyncio.get_event_loop().stop()?你正在停止事件循环
标签: python python-asyncio