On Fri, 2011-10-21 at 16:28 +0200, Zdeněk Pavlas wrote:
> Add 'external = True' flag to parallel_wait()
> to relay download requests to external process.

 Have you tried on RHEL-6 with ssl cert. repos?

> ---
>  urlgrabber/grabber.py |   80 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 78 insertions(+), 2 deletions(-)
> 
> diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
> index 6d75c31..953c997 100644
> --- a/urlgrabber/grabber.py
> +++ b/urlgrabber/grabber.py
> @@ -1951,6 +1951,81 @@ def download_process():
>      dl.abort()
>      sys.exit(0)
>  
> +import subprocess
> +
> +class _ExternalDownloader:
> +    def __init__(self):
> +        self.popen = subprocess.Popen(
> +            ['/usr/bin/python', __file__, 'DOWNLOADER'],
> +            stdin = subprocess.PIPE,
> +            stdout = subprocess.PIPE,
> +        )

 Dito. __file__ comments. What happens with C-c etc.?

> +        self.stdin  = self.popen.stdin.fileno()
> +        self.stdout = self.popen.stdout.fileno()

 Name these better, so we aren't constantly reading from "stdout" and
writing to "stdin".

> +    def perform(self):
> +        ret = []
> +        buf = os.read(self.stdout, 4096)
> +        while buf:
> +            try: line, buf = buf.split('\n', 1)
> +            except ValueError:
> +                buf += os.read(self.stdout, 4096)
> +                continue

 Dito. blocking readline.

> +            # parse downloader output
> +            line = line.split(' ', 3)
> +            cnt, _amount_read = map(int, line[:2])
> +            if len(line) == 2:
> +                m = self.running[cnt].progress_obj
> +                if m:
> +                    if not m.last_update_time: m.start()
> +                    m.update(_amount_read)
> +                continue
> +            # job done
> +            opts = self.running.pop(cnt)
> +            err = None
> +            if line[2] != 'OK':
> +                err = URLGrabError(int(line[2]), line[3])
> +            ret.append((opts, err, _amount_read))
> +        return ret
> +
> +    def abort(self):
> +        self.popen.stdin.close()
> +        self.popen.stdout.close()
> +        self.popen.wait()
> +

_______________________________________________
Yum-devel mailing list
Yum-devel@lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to