diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-10-15 15:13:41 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-10-15 15:13:41 +0200 |
commit | 1ce7f9e4e2f113e1ddcde78ba24a916a01d0fe15 (patch) | |
tree | 7510ddb4e274c56ce33e2e1c2d3a64f1596566b2 /module/plugins | |
parent | fix for last commit (diff) | |
download | pyload-1ce7f9e4e2f113e1ddcde78ba24a916a01d0fe15.tar.xz |
different workaround
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 26 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 15 |
2 files changed, 26 insertions, 15 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index aee8674ec..47f47bcaf 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -1,12 +1,34 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import sys import os from os import remove, chmod from os.path import exists, basename, isfile, isdir +import subprocess from traceback import print_exc from copy import copy + +# cleanup patch for older python versions +# see http://bugs.python.org/issue6122 +# http://bugs.python.org/issue1236 +# http://bugs.python.org/issue1731717 +if sys.version_info < (2, 6): + def _cleanup(): + pass + subprocess._cleanup = _cleanup + +def _old_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: + pass + + if os.name != "nt": from os import chown from pwd import getpwnam @@ -203,6 +225,10 @@ class ExtractArchive(Hook): if self.core.debug: print_exc() self.logError(basename(plugin.file), _("Unknown Error"), str(e)) + finally: + if sys.version_info < (2, 6): + # call cleanup when its seems save + _old_cleanup() return [] diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index e2a61c678..3f27c2e9e 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -18,25 +18,10 @@ """ 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 |