Replaced debug output of json.dumps with an indirection to lazy __str__.

json.dumps is a processing intensive operation. This is being called
every time data is received from the server (most noticeably during
library updates) for debug logging. If the user has debug logging
disabled (the default option) then the user is still paying for
processing which is discarded.

The fix is to add a level of indirection where the dumps function is
only called if a string representation of the json is requested; ie.
when the debug string is evaluated.
This commit is contained in:
Chuddah 2020-02-16 22:17:05 +00:00
parent 94456ddcd8
commit 7491000a13
5 changed files with 24 additions and 8 deletions

View file

@ -15,7 +15,7 @@ import client
from database import reset, get_sync, Database, jellyfin_db, get_credentials
from objects import Objects, Actions
from downloader import TheVoid
from helper import translate, event, settings, window, dialog, api, JSONRPC
from helper import translate, event, settings, window, dialog, api, JSONRPC, debug
#################################################################################################
@ -45,7 +45,7 @@ class Events(object):
if server == 'None':
server = None
LOG.info("path: %s params: %s", path, json.dumps(params, indent=4))
LOG.info("path: %s params: %s", path, debug.JsonDebugPrinter(params))
if '/extrafanart' in base_url: