[tasks] Log exception when something failed to logging.

This commit is contained in:
Rapptz 2019-05-13 21:10:26 -04:00
parent a62641bd65
commit a4a362b4c7

View File

@ -3,11 +3,14 @@ import aiohttp
import websockets import websockets
import discord import discord
import inspect import inspect
import logging
from discord.backoff import ExponentialBackoff from discord.backoff import ExponentialBackoff
MAX_ASYNCIO_SECONDS = 3456000 MAX_ASYNCIO_SECONDS = 3456000
log = logging.getLogger(__name__)
class Loop: class Loop:
"""A background task helper that abstracts the loop and reconnection logic for you. """A background task helper that abstracts the loop and reconnection logic for you.
@ -86,6 +89,9 @@ class Loop:
except asyncio.CancelledError: except asyncio.CancelledError:
self._is_being_cancelled = True self._is_being_cancelled = True
raise raise
except Exception as e:
log.exception('Internal background task failed.')
raise
finally: finally:
await self._call_loop_function('after_loop') await self._call_loop_function('after_loop')
self._is_being_cancelled = False self._is_being_cancelled = False