clinton-hall / nzbToMedia

Provides NZB and Torrent postprocessing To CouchPotatoServer, SickBeard/SickRage, HeadPhones, Mylar and Gamez
GNU General Public License v3.0
670 stars 176 forks source link

Script Hangs on Aborted jobs #180

Closed bnevets27 closed 10 years ago

bnevets27 commented 11 years ago

nzbToCouchPotato.py Script just hangs when trying to process an aborted job in sabnzbd. It will hang for either an encrypted or missing articles job. If I kill the script process the script completes.

In sabnzbd history while its hung reads forever: » Running script: nzbToCouchPotato.py » Aborted, cannot be completed

If I kill the script process then the script finishes as it should with this output: "13:50:32|INFO ==================== 13:50:32|INFO nzbToCouchPotato V8.4 13:50:32|INFO Script triggered from SABnzbd, starting autoProcessMovie... 13:50:32|INFO Loading config from /mnt/scratch/plugins/data/sabnzbd/scriptsnew/autoProcessMedia.cfg 13:50:32|INFO Found movie id tt1670345 in name 13:50:33|INFO Found movie id 204 in CPS database for movie tt1670345 13:50:33|INFO Found a total of 2 releases snatched for clientAgent: sabnzbd. Cannot determine download_id. Will perform a renamenr scan to try and process. 13:50:33|INFO Download of xxxxxxxxxxxxxxxxx.cp(tt1670345).nzb has failed. 13:50:33|INFO Trying to re-cue the next highest ranked release"

I'm not sure why the script is failing on aborted jobs. I don't know were there is an output of the script that might give me an idea. I can provide more info if needed.

sabnzbd settings are: empty_postproc - is on Action when encrypted RAR is downloaded - Abort Abort jobs that cannot be completed - is on

clinton-hall commented 11 years ago

So killing the script process actually allows the script to complete? This sounds like the script is running 2 instances?

bnevets27 commented 11 years ago

When I run "ps aux | grep sabnzbd" I get one process for sabnzbd and one for the currently hung script. If I kill the process for the script then I get that script output shown above. The biggest issue is when the script hangs it prevents any download after it to process which cause sabnzb to be stuck waiting on the script to finish. This only happens on downloads that are aborted. The script runs fine on clean downloads.

clinton-hall commented 11 years ago

SABnzbd must have changed the way it runs scripts when downloads are aborted? It has to be the process that launches the script, as clearly the script does run once that process is killed. Can you post on SABnzbd forums? I am happy to make necessary changes and am not claiming my script is NOT to blame, but I cant see how at this time. if they can give you more info I can fix if/as necessary.

bnevets27 commented 11 years ago

I'll make a post on the SABnzbd forums. Just so I can test, do you know what version of sabnzbd that the script ran fine on aborted jobs? That way I can revert back just to confirm it was a change made by sabnzbd. Not blaming your script but then I can rule out a couple scenarios. I'm currently on 0.7.16 and I haven't been using your script for too long so I haven't used it on previous sabnzbd versions.

New development: Well I just checked my sabnzbd history and it looks liked it dealt with 4 aborted jobs without hanging. I had made one change to see if it would fix it. I turned on: "delete_failed = 1" so far it looks like that worked. I'll test a bit more, unless that was supposed to be on "by default" to allow the script to run properly. EDIT: Looks to be running fine with "delete_failed = 0" now. I don't know what happened between yesterday and today. Sorry to have bugged you.

Thanks for the great script and all your hard work!

clinton-hall commented 11 years ago

The last time I had a failed job on SABnzbd was on 0.7.11 (that is when I switched to NZBGet on my NAS do my regular downloading).

bnevets27 commented 11 years ago

Well it looks like the problem is intermittent. I seems like the script takes a long time to run on aborted jobs which might have been why I thought it was hanging. But on multiple occasions I've waited over night and the script is still running, and just now it was stuck on a download job for two days. So it does defiantely hang but it has also I'll try an older version of sabnzbd when I get a chance.

fschoenm commented 10 years ago

I have the same problem with SABNZbd and CouchPotato . The postprocess.log shows the following output:

18:01:55|INFO nzbToCouchPotato V8.5 18:01:55|INFO Script triggered from SABnzbd, starting autoProcessMovie... 18:01:55|INFO Loading config from /usr/local/share/nzb/autoProcessMedia.cfg 18:01:55|INFO Found movie id tt0000000 in name 18:01:55|DEBUG Opening URL: http://localhost:8082/api/xxxxx/movie.list/?status=active 18:01:57|INFO Found movie id 253 in CPS database for movie tt0000000 18:01:57|DEBUG Looking for status of movie: 253 - with release sent to clientAgent: sabnzbd and download_id: 18:01:57|DEBUG Opening URL: http://localhost:8082/api/xxxxx/movie.get/?id=253 18:01:57|DEBUG This movie is marked as status active in CouchPotatoServer 18:01:57|DEBUG Found a single download_id: SABnzbd_nzo_J8AMy2 and clientAgent: Sabnzbd. Release status is: snatched 18:01:57|INFO Download of xxxxx.nzb has failed. 18:01:57|INFO Trying to re-cue the next highest ranked release 18:01:57|DEBUG Opening URL: http://localhost:8082/api/xxxxx/movie.searcher.try_next/?id=253

The next logging line from the script

    Logger.info("Movie %s set to try the next best release on CouchPotatoServer", movie_id)

is not executed I think (not in the log file) so it looks as if CouchPotato never answers the HTTP request. I also cannot access the CouchPotato web app while the script is running. As the problem appears to be in CouchPotato itself, maybe the only thing that can be done in the script is to add some kind of time out for the API request to make sure that it does not block the entire system.

clinton-hall commented 10 years ago

I have just added timeout to all URL calls in dev branch.

At this time I am waiting for CouchPotato to merge the develop branch into master... When that happens I'll merge dev branch into master here, but now I named to separate them as the Api calls have changed in CouchPotato and I need to keep these in sync.