Closed
Description
It appears that if you use a coroutine as a sink and it has an unhandled exception, even with catch=True
specified in add()
, the exception is not caught, and you will get a Task exception was never retrieved
error on stderr from asyncio: https://docs.python.org/3/library/asyncio-dev.html#detect-never-retrieved-exceptions
import asyncio
from loguru import logger
async def sink(msg):
raise Exception("oh no")
async def main():
logger.add(sink, catch=True)
logger.info("hello world")
asyncio.run(main())
2020-03-23 12:31:58.236 | INFO | main:main:3 - hello world
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<sink() done, defined at :1> exception=Exception('oh no')>
Traceback (most recent call last):
File "", line 2, in sink
Exception: oh no