Browse Source

[tasks] Log exception when something failed to logging.

pull/2161/head
Rapptz 6 years ago
parent
commit
a4a362b4c7
  1. 6
      discord/ext/tasks/__init__.py

6
discord/ext/tasks/__init__.py

@ -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

Loading…
Cancel
Save