summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-10-15 14:58:38 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-10-15 14:58:38 +0200
commitd6cc9b02eb7bbd7c77f4493ab163c8b930825ff6 (patch)
tree540fd278fc3c886c89e9ff7ea3df2b55298f3826
parentfixes for unrar (diff)
downloadpyload-d6cc9b02eb7bbd7c77f4493ab163c8b930825ff6.tar.xz
subprocess bug workaround
-rw-r--r--module/plugins/internal/UnRar.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index 9aff4bb8e..44c02b686 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -18,10 +18,26 @@
"""
import os
+import sys
from os.path import join
from glob import glob
+import subprocess
from subprocess import Popen, PIPE
+def _cleanup():
+ for inst in subprocess._active[:]:
+ res = inst._internal_poll(_deadstate=sys.maxint)
+ if res is not None and res >= 0:
+ try:
+ subprocess._active.remove(inst)
+ except ValueError:
+ # This can happen if two threads create a new Popen instance.
+ # It's harmless that it was already removed, so ignore.
+ pass
+
+# cleanup patch for older python versions
+subprocess._cleanup = _cleanup()
+
from module.plugins.hooks.ExtractArchive import AbtractExtractor
from module.utils import save_join, decode