Skip to content

Commit

Permalink
Fix logging handler management when reloading
Browse files Browse the repository at this point in the history
The main module was removing the `_logging` module without invoking
`plugin_unloaded`, which lead to the module being reloaded without the
previous handler being cleaned up and causing duplicate logging events,
especially when reloading the package with the
AutomaticPackageReloader.
  • Loading branch information
FichteFoll committed Jan 28, 2024
1 parent 2481199 commit 9b97ab8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import sys

# clear modules cache if package is reloaded (after update?)
prefix = __package__ + "." # don't clear the base package
prefix = __package__ + ".plugins" # don't clear the base package
for module_name in [
module_name
for module_name in sys.modules
if module_name.startswith(prefix) and module_name != __name__
if module_name.startswith(prefix)
]:
del sys.modules[module_name]
prefix = None
del prefix

from .plugins import * # noqa

0 comments on commit 9b97ab8

Please sign in to comment.