mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
Disabled more maintenance nonsense when running tasks
This commit is contained in:
parent
19de87cb66
commit
55363bf31b
@ -23,11 +23,13 @@ if malojaconfig['USE_GLOBAL_CACHE']:
|
||||
@runhourly
|
||||
def maintenance():
|
||||
from . import AUX_MODE
|
||||
if not AUX_MODE:
|
||||
if AUX_MODE: return
|
||||
print_stats()
|
||||
trim_cache()
|
||||
|
||||
def print_stats():
|
||||
from . import AUX_MODE
|
||||
if AUX_MODE: return
|
||||
for name,c in (('Cache',cache),('Entity Cache',entitycache)):
|
||||
hits, misses = c.get_stats()
|
||||
log(f"{name}: Size: {len(c)} | Hits: {hits}/{hits+misses} | Estimated Memory: {human_readable_size(c)}")
|
||||
@ -35,6 +37,8 @@ if malojaconfig['USE_GLOBAL_CACHE']:
|
||||
|
||||
|
||||
def cached_wrapper(inner_func):
|
||||
from . import AUX_MODE
|
||||
if AUX_MODE: return inner_func
|
||||
|
||||
def outer_func(*args,**kwargs):
|
||||
|
||||
@ -59,6 +63,8 @@ if malojaconfig['USE_GLOBAL_CACHE']:
|
||||
# we don't want a new cache entry for every single combination, but keep a common
|
||||
# cache that's aware of what we're calling
|
||||
def cached_wrapper_individual(inner_func):
|
||||
from . import AUX_MODE
|
||||
if AUX_MODE: return
|
||||
|
||||
def outer_func(set_arg,**kwargs):
|
||||
if 'dbconn' in kwargs:
|
||||
@ -83,6 +89,9 @@ if malojaconfig['USE_GLOBAL_CACHE']:
|
||||
return outer_func
|
||||
|
||||
def invalidate_caches(scrobbletime=None):
|
||||
from . import AUX_MODE
|
||||
if AUX_MODE: return
|
||||
|
||||
cleared, kept = 0, 0
|
||||
for k in cache.keys():
|
||||
# VERY BIG TODO: differentiate between None as in 'unlimited timerange' and None as in 'time doesnt matter here'!
|
||||
@ -95,10 +104,14 @@ if malojaconfig['USE_GLOBAL_CACHE']:
|
||||
|
||||
|
||||
def invalidate_entity_cache():
|
||||
from . import AUX_MODE
|
||||
if AUX_MODE: return
|
||||
entitycache.clear()
|
||||
|
||||
|
||||
def trim_cache():
|
||||
from . import AUX_MODE
|
||||
if AUX_MODE: return
|
||||
ramprct = psutil.virtual_memory().percent
|
||||
if ramprct > malojaconfig["DB_MAX_MEMORY"]:
|
||||
log(f"{ramprct}% RAM usage, clearing cache!")
|
||||
|
@ -1360,8 +1360,8 @@ def search_album(searchterm,dbconn=None):
|
||||
def clean_db(dbconn=None):
|
||||
|
||||
from . import AUX_MODE
|
||||
if AUX_MODE: return
|
||||
|
||||
if not AUX_MODE:
|
||||
with SCROBBLE_LOCK:
|
||||
log(f"Database Cleanup...")
|
||||
|
||||
@ -1407,6 +1407,10 @@ def clean_db(dbconn=None):
|
||||
|
||||
@runmonthly
|
||||
def renormalize_names():
|
||||
|
||||
from . import AUX_MODE
|
||||
if AUX_MODE: return
|
||||
|
||||
with SCROBBLE_LOCK:
|
||||
with engine.begin() as conn:
|
||||
rows = conn.execute(DB['artists'].select()).all()
|
||||
|
Loading…
x
Reference in New Issue
Block a user