Twisted 147 error at Debian 12 (RPI)

General support for problems installing or using Deluge
Post Reply
Faranos
New User
New User
Posts: 1
Joined: Sat Sep 28, 2024 7:10 pm

Twisted 147 error at Debian 12 (RPI)

Post by Faranos »

Good evening everyone,

I’m new here and have a small problem, hoping you can help me.

I have a Raspberry Pi 4 that unfortunately crashed. I reinstalled it (Raspberry Pi OS Lite - Debian 12 Bookworm).

I’ve now installed deluged and deluge-console and wanted to start it via

Code: Select all

deluged
.

However, I’m getting a massive error message.

Code: Select all

 Unhandled error in Deferred:
20:31:53 [CRITICAL][twisted                       :147 ] Unhandled error in Deferred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/deluge/common.py", line 1344, in run_profiled
    return func(*args)
  File "/usr/lib/python3/dist-packages/deluge/core/daemon_entry.py", line 124, in run_daemon
    log.error(
  File "/usr/local/lib/python3.11/dist-packages/twisted/internet/defer.py", line 2287, in unwindGenerator
    return _cancellableInlineCallbacks(gen)
  File "/usr/local/lib/python3.11/dist-packages/twisted/internet/defer.py", line 2197, in _cancellableInlineCallbacks
    _inlineCallbacks(None, gen, status, _copy_context())
--- <exception caught here> ---
  File "/usr/local/lib/python3.11/dist-packages/twisted/internet/defer.py", line 2014, in _inlineCallbacks
    result = context.run(gen.send, result)
  File "/usr/lib/python3/dist-packages/deluge/log.py", line 79, in error
    yield LoggingLoggerClass.error(self, msg, *args, **kwargs)
  File "/usr/lib/python3.11/logging/__init__.py", line 1518, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python3.11/logging/__init__.py", line 1622, in _log
    fn, lno, func, sinfo = self.findCaller(stack_info, stacklevel)
builtins.TypeError: Logging.findCaller() takes from 1 to 2 positional arguments but 3 were given

Temporarily disabling observer LegacyLogObserverWrapper(<bound method TwistedLoggingObserver.emit of <deluge.log.TwistedLoggingObserver object at 0x7f9ac78850>>) due to exception: [Failure instance: Traceback: <class 'TypeError'>: Logging.findCaller() takes from 1 to 2 positional arguments but 3 were given
/usr/lib/python3/dist-packages/deluge/core/daemon_entry.py:124:run_daemon
/usr/local/lib/python3.11/dist-packages/twisted/internet/defer.py:386:__del__
/usr/local/lib/python3.11/dist-packages/twisted/logger/_logger.py:281:failure
/usr/local/lib/python3.11/dist-packages/twisted/logger/_logger.py:226:emit
--- <exception caught here> ---
/usr/local/lib/python3.11/dist-packages/twisted/logger/_observer.py:81:__call__
/usr/local/lib/python3.11/dist-packages/twisted/logger/_legacy.py:90:__call__
/usr/lib/python3/dist-packages/deluge/log.py:204:emit
/usr/lib/python3.11/logging/__init__.py:1536:critical
/usr/lib/python3.11/logging/__init__.py:1622:_log
]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/deluge/core/daemon_entry.py", line 124, in run_daemon
    log.error(
  File "/usr/local/lib/python3.11/dist-packages/twisted/internet/defer.py", line 386, in __del__
    log.failure(format, self.failResult, debugInfo=debugInfo)
  File "/usr/local/lib/python3.11/dist-packages/twisted/logger/_logger.py", line 281, in failure
    self.emit(level, format, log_failure=failure, **kwargs)
  File "/usr/local/lib/python3.11/dist-packages/twisted/logger/_logger.py", line 226, in emit
    self.observer(event)
--- <exception caught here> ---
  File "/usr/local/lib/python3.11/dist-packages/twisted/logger/_observer.py", line 81, in __call__
    observer(event)
  File "/usr/local/lib/python3.11/dist-packages/twisted/logger/_legacy.py", line 90, in __call__
    self.legacyObserver(event)
  File "/usr/lib/python3/dist-packages/deluge/log.py", line 204, in emit
    getattr(LoggingLoggerClass, event_dict['log_level'].name)(
  File "/usr/lib/python3.11/logging/__init__.py", line 1536, in critical
    self._log(CRITICAL, msg, args, **kwargs)
  File "/usr/lib/python3.11/logging/__init__.py", line 1622, in _log
    fn, lno, func, sinfo = self.findCaller(stack_info, stacklevel)
builtins.TypeError: Logging.findCaller() takes from 1 to 2 positional arguments but 3 were given
Unfortunately, I’m completely new to Raspberry Pi since I usually use Windows and I’m not very familiar with the commands and directories.

I found a thread in the forum that contains a fix. I tried running

Code: Select all

 sudo pip3 install --upgrade twisted
, but I encountered an error message there as well. I tried to work around it with

Code: Select all

sudo pip3 install --upgrade twisted --break-system-packages
, and that worked. However, I still get the error message when I call deluged.

The thread also mentions that I should install a patch for "log.py," but I’m not sure how to do that.

I hope you can help this noob!
User avatar
ambipro
Moderator
Moderator
Posts: 551
Joined: Thu May 19, 2022 3:33 am
Contact:

Re: Twisted 147 error at Debian 12 (RPI)

Post by ambipro »

The correct versions for packages and deps are stated in requirements.txt in the repository on GitHub if you're confused, I'm not sure if you have other packages depending on packages outside the requirements, but you can always use something like an isolated environment (venv) to work around this.
mhertz
Moderator
Moderator
Posts: 2272
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Twisted 147 error at Debian 12 (RPI)

Post by mhertz »

In addition to our helpful good folk, ambipro's sound advice, then just quickly wanted add the log patch you mentioned is needed, didn't I write a command-line to just copy/paste? Sorry little lazy to go hunt myself, and can hear you already found. Otherwise need make manual change, very small fix.

Anyway, I can help you in depth if really need it, later/tomorrow probably knowing me :)
mhertz
Moderator
Moderator
Posts: 2272
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Twisted 147 error at Debian 12 (RPI)

Post by mhertz »

Just in case, as felt bad about lazy responce last :)

Code: Select all

sudo find /usr -path '*-packages/deluge/log.py' -exec sed -i 's/stack_info=False/*args, **kwargs/' {} \;
If not comfortable using that command-line, which is fully understandable, then instead make the small change manually in '/usr/lib/python3/dist-packages/deluge/log.py': https://git.deluge-torrent.org/deluge/c ... ed0f2c3206

(The top command-line isn't using your direct path as can be seen in your logging, to be usable for others having same issue, e.g. /usr/local/lib/python/* source based installs, *site-packages* instead of *dist-*packages* depending on install method; and varying python version.)
Post Reply