Right now I call my processing scripts through another post processing script (lets call it "caller"). I'd like to modify my "caller" script so sab post-processes downloads asynchronously, How can I do that?
"caller" is written in perl although bash solutions are also welcome.
Thank you.
Call a pp script and inmediately continue after.
Call a pp script and inmediately continue after.
Last edited by sadnem on February 11th, 2012, 10:32 am, edited 1 time in total.
Re: Call a pp script and inmediately continue after.
Solution: the task in the script should start in the background so that the script itself can return/exit immediately.
On Linux (on Mac OS X?), starting a process in the background is easy: add a " &" at the end. Maybe a "nohup" is needed.
EDIT: On Windows it seems to work with "START ... /B"
On Linux (on Mac OS X?), starting a process in the background is easy: add a " &" at the end. Maybe a "nohup" is needed.
EDIT: On Windows it seems to work with "START ... /B"
Re: Call a pp script and inmediately continue after.
SABnzbd doesn't stop downloading during post-processing (unless you enabled that particular option).
The post-processing items do execute only sequentially.
The post-processing items do execute only sequentially.
Re: Call a pp script and inmediately continue after.
Yes, my mistake, main post edited.shypike wrote:SABnzbd doesn't stop downloading during post-processing (unless you enabled that particular option).
The post-processing items do execute only sequentially.
I'd like to post-process multiple items at once, I've tried to implement sander's suggentions in my "caller" script (bash) in a way like this:
Code: Select all
nohup perl mainscript "some arguments" &
exit
Re: Call a pp script and inmediately continue after.
I can confirm the behavior in SAB; only one post process process seems to be running.
So I did some test programming in python, and with "os.popen(cmd)" python waits for the script to end before continuing; a & does not help. So that could very well the reason for SAB's sequential behavior.
I did some further python programming, and with a 'os.spawnle(os.P_NOWAIT,cmd,'')' python does not wait for the process to end.
So I see two solutions:
- you change the SAB source code to use a s.spawnle(os.P_NOWAIT,cmd,'') for the post processing script
- do not change SAB, but let SAB just run a PP script to put something in a queue, and then returns immediately. You should have a separate program /daemon checking the queue and processing it.
But now my question: *why* do you want to have parallel post-processing scripts?
So I did some test programming in python, and with "os.popen(cmd)" python waits for the script to end before continuing; a & does not help. So that could very well the reason for SAB's sequential behavior.
I did some further python programming, and with a 'os.spawnle(os.P_NOWAIT,cmd,'')' python does not wait for the process to end.
So I see two solutions:
- you change the SAB source code to use a s.spawnle(os.P_NOWAIT,cmd,'') for the post processing script
- do not change SAB, but let SAB just run a PP script to put something in a queue, and then returns immediately. You should have a separate program /daemon checking the queue and processing it.
But now my question: *why* do you want to have parallel post-processing scripts?
Re: Call a pp script and inmediately continue after.
I'm sorry for my delay answering, I couldn't reply as I was busy with a project of mine.
(I'm supposing the first result is the correct one)
How could I turn that os.popen4 into a os.spawnle(os.P_NOWAIT,cmd,'')?
Well because my post-processing scripts take a relatively long time but don't use a lot of computer resources, therefore, letting my computer just wait seems like a waste of time. I hate seeing my downloads queued knowing that they could have been finished if my scripts were executed asynchronously.sander wrote:But now my question: *why* do you want to have parallel post-processing scripts?
as for this option (which seems like the one I'd like to go for) I've searched in /usr/share/sabnzbdplus/ for "os.popen" and would came up with these results:sander wrote:- you change the SAB source code to use a s.spawnle(os.P_NOWAIT,cmd,'') for the post processing script
Code: Select all
user@comp:/usr/share/sabnzbdplus# grep -r "popen" *
cherrypy/_cpmodpy.py: pipein, pipeout = os.popen4("%s %s" % (cmd, args))
cherrypy/_cpmodpy.py: os.popen("apache -k stop")
Binary file cherrypy/_cpmodpy.pyc matches
How could I turn that os.popen4 into a os.spawnle(os.P_NOWAIT,cmd,'')?
Re: Call a pp script and inmediately continue after.
there are also "Popen" occurences:
But, strangely enough, sabnzbd/postproc.py (which sounds like the post processor) has no Popen. So you have to find out where the post processing script is started ...
Code: Select all
$ grep -i popen *.py */*.py
SABHelper.py: return subprocess.Popen('net start SABnzbd', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stdout.read()
cherrypy/_cpmodpy.py: pipein, pipeout = os.popen4("%s %s" % (cmd, args))
cherrypy/_cpmodpy.py: os.popen("apache -k stop")
sabnzbd/__init__.py: subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE,
sabnzbd/misc.py: p = subprocess.Popen(program, shell=False, stdin=subprocess.PIPE,
sabnzbd/newsunpack.py: os_version = subprocess.Popen("sw_vers -productVersion", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stdout.read()
sabnzbd/newsunpack.py: p = subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE,
sabnzbd/newsunpack.py: p = subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE,
sabnzbd/newsunpack.py: p = subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE,
sabnzbd/newsunpack.py: p = subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE,
sabnzbd/newsunpack.py: p = subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE,
sabnzbd/newsunpack.py: # Work-around for bug in Python's Popen function,
sabnzbd/newsunpack.py: version = subprocess.Popen(rar, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stdout.read()
sabnzbd/newsunpack.py: p = subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE,
sabnzbd/newsunpack.py: p = subprocess.Popen(command, shell=need_shell, stdin=subprocess.PIPE,
sabnzbd/powersup.py: subprocess.Popen("rundll32 powrprof.dll,SetSuspendState Hibernate")
sabnzbd/powersup.py: subprocess.Popen("rundll32 powrprof.dll,SetSuspendState Standby")