Only log output and write progress to db if it has changed
authorSebastian Spaeth <Sebastian@SSpaeth.de>
Wed, 19 Dec 2012 14:43:38 +0000 (15:43 +0100)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Wed, 19 Dec 2012 14:48:30 +0000 (15:48 +0100)
De-noisify the transcoding log and db updates. Previously we would log
and save the progress percentage every second, even if it had not changed
at all. Save progress:oercentage in the Transcoder and only log/update
when the percentage has actually changed.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
mediagoblin/media_types/video/transcoders.py

index 26f96b5f227ca42115a01fdf245f6e1e5e403444..152de288d2385a123d32f8a8acd5b37b03ff5493 100644 (file)
@@ -636,7 +636,7 @@ class VideoTranscoder:
     '''
     def __init__(self):
         _log.info('Initializing VideoTranscoder...')
-
+        self.progress_percentage = None
         self.loop = gobject.MainLoop()
 
     def transcode(self, src, dst, **kwargs):
@@ -913,12 +913,14 @@ class VideoTranscoder:
         elif message.type == gst.MESSAGE_ELEMENT:
             if message.structure.get_name() == 'progress':
                 data = dict(message.structure)
-
-                if self._progress_callback:
-                    self._progress_callback(data.get('percent'))
-
-                _log.info('{percent}% done...'.format(
-                        percent=data.get('percent')))
+                # Update progress state if it has changed
+                if self.progress_percentage != data.get('percent'):
+                    self.progress_percentage = data.get('percent')
+                    if self._progress_callback:
+                        self._progress_callback(data.get('percent'))
+
+                    _log.info('{percent}% done...'.format(
+                            percent=data.get('percent')))
                 _log.debug(data)
 
         elif t == gst.MESSAGE_ERROR: