Opened 9 months ago

Last modified 8 months ago

#3326 new bug

Unhandled error in deferred handle_alerts

Reported by: pLurium Owned by:
Priority: major Milestone: 2.0.4
Component: Core Version: 2.0.3
Keywords: Cc:

Description

[CRITICAL][twisted                       :154 ] Unhandled error in Deferred:
[CRITICAL][deluge.log                    :93  ] twisted.internet.defer
[Failure instance: Traceback: <class 'UnicodeDecodeError'>: 'utf-8' codec can't decode byte 0xce in position 0: invalid continuation byte
/usr/local/lib/python3.7/dist-packages/twisted/internet/base.py:1283:run
/usr/local/lib/python3.7/dist-packages/twisted/internet/base.py:1292:mainLoop
/usr/local/lib/python3.7/dist-packages/twisted/internet/base.py:913:runUntilCurrent
/usr/local/lib/python3.7/dist-packages/twisted/internet/task.py:239:__call__
--- <exception caught here> ---
/usr/local/lib/python3.7/dist-packages/twisted/internet/defer.py:151:maybeDeferred
/usr/lib/python3/dist-packages/deluge/core/alertmanager.py:70:update
/usr/lib/python3/dist-packages/deluge/core/alertmanager.py:140:handle_alerts
/usr/lib/python3/dist-packages/deluge/core/alertmanager.py:141:<dictcomp>

Deluge doesn't completely crash but at least stops updating the user interfaces.

A simple workaround for now is catching the exception:

diff --git a/deluge/core/alertmanager.py b/deluge/core/alertmanager.py
index 2fe42224d..fedc48322 100644
--- a/deluge/core/alertmanager.py
+++ b/deluge/core/alertmanager.py
@@ -131,17 +131,20 @@ def handle_alerts(self):
             # Call any handlers for this alert type
             if alert_type in self.handlers:
                 for handler in self.handlers[alert_type]:
-                    if log.isEnabledFor(logging.DEBUG):
-                        log.debug('Handling alert: %s', alert_type)
-                    # Copy alert attributes
-                    alert_copy = SimpleNamespace(
-                        **{
-                            attr: getattr(alert, attr)
-                            for attr in dir(alert)
-                            if not attr.startswith('__')
-                        }
-                    )
-                    self.delayed_calls.append(reactor.callLater(0, handler, alert_copy))
+                    try:
+                        if log.isEnabledFor(logging.DEBUG):
+                            log.debug('Handling alert: %s', alert_type)
+                        # Copy alert attributes
+                        alert_copy = SimpleNamespace(
+                            **{
+                                attr: getattr(alert, attr)
+                                for attr in dir(alert)
+                                if not attr.startswith('__')
+                            }
+                        )
+                        self.delayed_calls.append(reactor.callLater(0, handler, alert_copy))
+                    except:
+                        pass
 
     def set_alert_queue_size(self, queue_size):
         """Sets the maximum size of the libtorrent alert queue"""

Change History (2)

comment:1 Changed 8 months ago by Cas

  • Milestone changed from needs verified to 2.0.4

Can you provide any details on how to replicate this error?

comment:2 Changed 8 months ago by pLurium

I had lots of

[WARNING ][deluge.core.torrentmanager    :1624] on_alert_performance: SomeTörrentNäme: performance warning: max outstanding piece requests reached, outstanding_request_limit_reached

and I think the name in one of them triggered the UnicodeDecodeError. I've upgraded earlier from Deluge 1.3 but didn't immediately run into this very problem but I've had other UnicodeDecodeError problems when loading old torrents.

Directly after upgrade I had to add

diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py
index b94868776..87549215c 100644
--- a/deluge/core/torrentmanager.py
+++ b/deluge/core/torrentmanager.py
@@ -1389,9 +1390,12 @@ def on_alert_tracker_error(self, alert):
         error_message = decode_bytes(alert.error_message())
         if not error_message:
             error_message = decode_bytes(alert.error.message())
-        log.debug(
-            'Tracker Error Alert: %s [%s]', decode_bytes(alert.message()), error_message
-        )
+        try:
+            log.debug(
+                'Tracker Error Alert: %s [%s]', decode_bytes(alert.message()), error_message
+            )
+        except:
+            pass
         torrent.set_tracker_status('Error: ' + error_message)
 
     def on_alert_storage_moved(self, alert):

so variations on a basic problem perhaps.

Last edited 8 months ago by pLurium (previous) (diff)
Note: See TracTickets for help on using tickets.