Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Delgan opened this issue Apr 6, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@Delgan
Copy link
Owner

Delgan commented Apr 6, 2020

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

@Delgan Delgan added bug Something isn't working enhancement Improvement to an already existing feature labels Apr 6, 2020
@Delgan Delgan changed the title Better handling for exception occurring while calling "stop()" from sink Exception occurring while calling "stop()" from sink prevent handler to be removed Apr 7, 2020
@Delgan Delgan removed the enhancement Improvement to an already existing feature label Apr 7, 2020
@Delgan Delgan closed this as completed Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant