the above code is not far from a quick-and-dirty standin for ionice:
Code: Select all
#!/usr/bin/env python
from ctypes import cdll
import sys, os, getopt
# chomp all the options that ionice takes.
# ignore them and simply set throttle priority
optlist,args = getopt.getopt(sys.argv[1:], 'tc:n:p:')
# load libc and set io priority for process
libc = cdll.LoadLibrary('libc.dylib')
boolSetResult=libc.setiopolicy_np(0,1,3)
# exec new process with set io priority
try:
os.execvp(args[0], args)
except IndexError:
print "missing process to execute"
this works as a standin for linux ionice. when placed in the path, the ionice options will appear in sab. fill in options that ionice would accept, and par2/unrar will run with throttle priority. worth note is that this will throttle reads only- osx seems not to be able to throttle writes. either way, this should make sure that a par2 verification doesn't slow down IO to the point where other IOs (i.e. for playback) can't be serviced.
.. or at least, i'd think it would. this wrapper works fine outside of sabnzbd, but when executed by sabnzbd, i can't get it to work. it silently and instantly fails, and the logs don't show why or how it was called. next hurdle to tackle..