Python asyncio - Loop-Exits mit Task wurden zerstört, stehen aber noch aus
Dies ist der relevante Code meines Python-Programms:
import discord
import asyncio
class Bot(discord.Client):
def __init__(self):
super().__init__()
@asyncio.coroutine
def my_background_task(self):
yield from self.wait_until_ready()
while not self.is_closed:
yield from asyncio.sleep(3600*24) # <- This is line 76 where it fails
doSomething()
bot = Bot()
loop = asyncio.get_event_loop()
try:
loop.create_task(bot.my_background_task())
loop.run_until_complete(bot.login('username', 'password'))
loop.run_until_complete(bot.connect())
except Exception:
loop.run_until_complete(bot.close())
finally:
loop.close()
Das Programm wird gelegentlich ohne andere Fehler oder Warnungen als @ beendet (obwohl dies nicht der Fall sein sollte
Task was destroyed but it is pending!
task: <Task pending coro=<my_background_task() running at bin/discordBot.py:76> wait_for=<Future pending cb=[Task._wakeup()]>>
Wie kann man sicherstellen, dass das Programm nicht zufällig beendet wird? Ich habe Python 3.4.3+ auf Xubuntu 15.10.