我正在尝试做这样的事情:
result_available = threading.Event() #variable was set outside of class
@commands.Cog.listener()
async def on_message(self, message):
thread = threading.Thread(target=self.messages, args=[message, 1])
if thread.isAlive():
return
thread.start()
result_available.wait()
#do some more stuff with it later
async def messages(self, message, limit):
if limit == 1:
await asyncio.sleep(3)
history = await message.channel.history(limit=limit).flatten()
if message.id not in history[-1]["id"]:
limit += 1
await self.messages(message, limit)
return
else:
result_available.set()
print("done")
return limit
但是当它出现错误时,因为“从未等待过协程'Drive.messages'”,而当我等待thread.start()时,我遇到了另一个错误。我该怎么办