Skip to content

Exception occurring while calling "stop()" from sink prevent handler to be removed #237

Closed
@Delgan

Description

Currently, if an exception occurs in stop(), the handle can't be removed:

loguru/loguru/_logger.py

Lines 979 to 997 in 00ee30f

with self._core.lock:
handlers = self._core.handlers.copy()
if handler_id is None:
for handler in handlers.values():
handler.stop()
handlers.clear()
else:
try:
handler = handlers.pop(handler_id)
except KeyError:
raise ValueError(
"There is no existing handler with id %d" % handler_id
) from None
handler.stop()
levelnos = (h.levelno for h in handlers.values())
self._core.min_level = min(levelnos, default=float("inf"))
self._core.handlers = handlers

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions