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

@ -20,7 +20,7 @@ import library
import setup
import monitor
from views import Views, verify_kodi_defaults
from helper import translate, window, settings, event, dialog
from helper import translate, window, settings, event, dialog, debug
from jellyfin import Jellyfin
#################################################################################################
@ -171,7 +171,7 @@ class Service(xbmc.Monitor):
data = json.loads(data)
LOG.debug("[ %s: %s ] %s", sender, method, json.dumps(data, indent=4))
LOG.debug("[ %s: %s ] %s", sender, method, debug.JsonDebugPrinter(data))
if method == 'ServerOnline':
if data.get('ServerId') is None: