Linux run command line on background from an addon
#1
I have just started to produce an add-on that runs a process in command line. this process can take up to 30 mins to complete. At the moment I get the "Working" information box in the corner. Is there a way of making this command line process run in the background so I can keep using the Kodi? I know the process that i am running is not processor hungry. I am running Kodibutu.
Any help on this would be grate.
Reply
#2
Start a thread (http://www.python-course.eu/threads.php) and use the subprocess module (https://docs.python.org/2/library/subprocess.html) in the function the thread calls (the one that runs the process/cmd). If you use the subprocess module instead of os.system(), you can communicate with the subprocess and access the stdout and the stderr. Also, the process will have a PID associated and you can know, from python, if it is still running.

Cheers
Reply
#3
I would guess your python script is blocking because you are using the call() method rather than Popen(). Perhaps showing the code itself would help here.

If the CLI itself is blocked, then you may want to add an ampersand (&) to the end of the command. Doing this would make your process run in the background. More technically the command is forked and run asynchronously in a separate sub-shell.
Reply
#4
Thank you both of you

Karnagious - putting the ampersand at the end worked perfect.
Reply

Logout Mark Read Team Forum Stats Members Help
run command line on background from an addon0