music-kraken-core/src/music_kraken/__init__.py

38 lines
1.0 KiB
Python
Raw Normal View History

2022-11-23 07:24:05 +00:00
import logging
2023-04-15 15:17:33 +00:00
import gc
2023-10-12 17:24:35 +00:00
import sys
2023-04-15 15:17:33 +00:00
2023-09-13 16:55:04 +00:00
from .utils.shared import DEBUG, DEBUG_LOGGIN
2023-09-10 14:27:09 +00:00
from .utils.config import logging_settings, main_settings, read_config
read_config()
from . import cli
2023-04-18 07:02:03 +00:00
2023-10-24 15:41:42 +00:00
if True:
import sys
sys.setrecursionlimit(100)
2023-09-10 14:27:09 +00:00
# configure logger default
logging.basicConfig(
2023-09-13 16:55:04 +00:00
level=logging_settings['log_level'] if not DEBUG_LOGGIN 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)