Page 1 of 1

SABnzbd / python exception on finishing manual download

Posted: January 5th, 2011, 2:07 am
by krackt
Not sure if this is the right forum so apologies if so.

SABnzbd crashes at the end of downloading if I manually start a download.
From sabnzbd.error.log:

Code: Select all

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "/usr/share/sabnzbdplus/sabnzbd/postproc.py", line 183, in run
    if self.queue.empty(): HandleEmptyQueue()
  File "/usr/share/sabnzbdplus/sabnzbd/postproc.py", line 576, in HandleEmptyQueue
    sabnzbd.QUEUECOMPLETEACTION(sabnzbd.QUEUECOMPLETEARG)
  File "/usr/share/sabnzbdplus/sabnzbd/__init__.py", line 596, in run_script
    stup, need_shell, command, creationflags = sabnzbd.newsunpack.build_command(command)
  File "/usr/share/sabnzbdplus/sabnzbd/newsunpack.py", line 1040, in build_command
    command.insert(0, arg)
AttributeError: 'str' object has no attribute 'insert'
I have a script that shuts down my pc once scheduled downloads are finished, but for manual downloads the queue script is set to None.

Process list looks like this afterwards:
xbmc  1440  0.3  0.7 356608 24600 ?  Sl  16:13  0:07 /usr/bin/python /usr/bin/sabnzbdplus --daemon --autorestarted

TIA for input on resolving this.

Re: SABnzbd / python exception on finishing manual download

Posted: January 5th, 2011, 5:16 am
by shypike
You have discovered a bug in SABnzbd.
It will only reveal itself when you set NICE or IONICE parameters in Config->Switches.
These parameters should not be used at all for an end-of-queue script
and in the current code they're used in the wrong way, causing the crash.

The only work-around now is to remove all NICE and IONICE parameters from Config->Switches.

The alternative is to patch the code in newsunpack.py.
Line 1034 is now:

Code: Select all

def build_command(command):
Insert this line after it:

Code: Select all

    if not isinstance(command, list): command = [command]
So the final code looks like this:

Code: Select all

def build_command(command):
    if not isinstance(command, list): command = [command]
    if not sabnzbd.WIN32:
Will be fixed in the next release.

Re: SABnzbd / python exception on finishing manual download

Posted: January 6th, 2011, 8:20 am
by krackt
Can confirm that inserting your code prevents the crash :) (...although the ionice command stll runs prior to the shutdown script)

I've removed the ionice parameters from my config for the time being. Thanks for your help and such great software.

Re: SABnzbd / python exception on finishing manual download

Posted: January 6th, 2011, 11:00 am
by shypike
krackt wrote: (...although the ionice command stll runs prior to the shutdown script)
Yes, this just removed the error.
It's not clear cut whether or not nice and ionice should be used.
Opinions will differ.
I don't think it hurts much to run it with nice/ionice.
It certainly makes to code simpler to use them always.
I'll make up my mind for 0.6.0

Re: SABnzbd / python exception on finishing manual download

Posted: January 7th, 2011, 8:50 am
by krackt
shypike wrote: It's not clear cut whether or not nice and ionice should be used.
Opinions will matter.
FWIW from my perspective SABnzbd is a perfect candidate for both "cpu" nice and ionice for managing cpu load generated by network and disk io from unrar.