mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 10:45:27 +00:00
Better logic for cleanup task. Skip gathering memory if we aren't going to log it anyway.
This commit is contained in:
parent
eb223e1df2
commit
06b1dec2b6
1 changed files with 5 additions and 2 deletions
|
|
@ -254,7 +254,10 @@ def cleanup_memory(log_usage=True, force_collection=True):
|
|||
log_usage: Whether to log memory usage before and after cleanup
|
||||
force_collection: Whether to force garbage collection
|
||||
"""
|
||||
logger.debug("Starting memory cleanup django memory cleanup")
|
||||
logger.trace("Starting memory cleanup django memory cleanup")
|
||||
# Skip logging if log level is not set to debug (no reason to run memory usage if we don't log it)
|
||||
if not logger.isEnabledFor(logging.DEBUG):
|
||||
log_usage = False
|
||||
if log_usage:
|
||||
try:
|
||||
import psutil
|
||||
|
|
@ -283,4 +286,4 @@ def cleanup_memory(log_usage=True, force_collection=True):
|
|||
logger.debug(f"Memory after cleanup: {after_mem:.2f} MB (change: {after_mem-before_mem:.2f} MB)")
|
||||
except (ImportError, Exception):
|
||||
pass
|
||||
logger.debug("Memory cleanup complete for django")
|
||||
logger.trace("Memory cleanup complete for django")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue