2022-11-23 07:24:05 +00:00
|
|
|
import logging
|
|
|
|
|
2023-04-15 15:17:33 +00:00
|
|
|
import gc
|
|
|
|
import musicbrainzngs
|
|
|
|
|
2023-09-11 19:34:45 +00:00
|
|
|
from .utils.shared import DEBUG
|
2023-09-10 14:27:09 +00:00
|
|
|
from .utils.config import logging_settings, main_settings, read_config
|
|
|
|
read_config()
|
2023-06-20 15:07:32 +00:00
|
|
|
from . import cli
|
2023-04-18 07:02:03 +00:00
|
|
|
|
2023-09-10 14:27:09 +00:00
|
|
|
|
|
|
|
# configure logger default
|
|
|
|
logging.basicConfig(
|
2023-09-11 19:34:45 +00:00
|
|
|
level=logging_settings['log_level'] if not DEBUG else logging.DEBUG,
|
2023-09-10 14:27:09 +00:00
|
|
|
format=logging_settings['logging_format'],
|
|
|
|
handlers=[
|
|
|
|
logging.FileHandler(main_settings['log_file']),
|
|
|
|
logging.StreamHandler()
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
if main_settings['modify_gc']:
|
2023-04-04 20:07:56 +00:00
|
|
|
"""
|
|
|
|
At the start I modify the garbage collector to run a bit fewer times.
|
|
|
|
This should increase speed:
|
|
|
|
https://mkennedy.codes/posts/python-gc-settings-change-this-and-make-your-app-go-20pc-faster/
|
|
|
|
"""
|
|
|
|
# Clean up what might be garbage so far.
|
|
|
|
gc.collect(2)
|
|
|
|
|
|
|
|
allocs, gen1, gen2 = gc.get_threshold()
|
|
|
|
allocs = 50_000 # Start the GC sequence every 50K not 700 allocations.
|
|
|
|
gen1 = gen1 * 2
|
|
|
|
gen2 = gen2 * 2
|
|
|
|
gc.set_threshold(allocs, gen1, gen2)
|