Browse Source

Trigger garbage collection every 5 minutes

Relates to #1736
pull/1748/head
Safihre 4 years ago
parent
commit
687deab6bc
  1. 14
      SABnzbd.py
  2. 4
      sabnzbd/postproc.py

14
SABnzbd.py

@ -34,6 +34,7 @@ import subprocess
import ssl import ssl
import time import time
import re import re
import gc
from typing import List, Dict, Any from typing import List, Dict, Any
try: try:
@ -1517,6 +1518,7 @@ def main():
timer = 0 timer = 0
while not sabnzbd.SABSTOP: while not sabnzbd.SABSTOP:
time.sleep(3) time.sleep(3)
timer += 1
# Check for loglevel changes # Check for loglevel changes
if LOG_FLAG: if LOG_FLAG:
@ -1526,9 +1528,15 @@ def main():
if console_logging: if console_logging:
console.setLevel(level) console.setLevel(level)
# 30 sec polling tasks # 300 sec polling tasks
if timer > 9: if not timer % 100:
if sabnzbd.LOG_ALL:
logging.debug("Triggering Python garbage collection")
gc.collect()
timer = 0 timer = 0
# 30 sec polling tasks
if not timer % 10:
# Keep OS awake (if needed) # Keep OS awake (if needed)
sabnzbd.keep_awake() sabnzbd.keep_awake()
# Restart scheduler (if needed) # Restart scheduler (if needed)
@ -1539,8 +1547,6 @@ def main():
if not sabnzbd.check_all_tasks(): if not sabnzbd.check_all_tasks():
autorestarted = True autorestarted = True
sabnzbd.TRIGGER_RESTART = True sabnzbd.TRIGGER_RESTART = True
else:
timer += 1
# 3 sec polling tasks # 3 sec polling tasks
# Check for auto-restart request # Check for auto-restart request

4
sabnzbd/postproc.py

@ -18,13 +18,13 @@
""" """
sabnzbd.postproc - threaded post-processing of jobs sabnzbd.postproc - threaded post-processing of jobs
""" """
import gc
import os import os
import logging import logging
import functools import functools
import subprocess import subprocess
import time import time
import re import re
import gc
import queue import queue
from typing import List, Optional from typing import List, Optional
@ -1039,9 +1039,7 @@ def handle_empty_queue():
sabnzbd.change_queue_complete_action(cfg.queue_complete(), new=False) sabnzbd.change_queue_complete_action(cfg.queue_complete(), new=False)
# Trigger garbage collection # Trigger garbage collection
logging.debug("Triggering Python garbage collection")
gc.collect() gc.collect()
logging.debug("Finished Python garbage collection")
def cleanup_list(wdir, skip_nzb): def cleanup_list(wdir, skip_nzb):

Loading…
Cancel
Save