[elbe-devel] [PATCH] soapclient: download_file: fix uninitialized retry

Kurt Kanzenbach kurt at linutronix.de
Wed Sep 5 12:51:40 CEST 2018


Hi,

On Wed, Sep 05, 2018 at 12:01:07PM +0200, John Ogness wrote:
> If an exception is generated from self.service.get_file(), the retry
> variable is decremented. But it was never initialized, resulting in
> the trace below. (The ret variable is also never initialized.)
> 
> I do not understand why retrying the download would help (in my case
> the elbe-daemon crashed), but I chose to initialize retry so that it
> retries once.

If retry doesn't work at all, why not remove the retry handling
completely?

Thanks,
Kurt

> 
> Traceback (most recent call last):
>   File "/usr/bin/elbe", line 55, in <module>
>     cmdmod.run_command(sys.argv[2:])
>   File "/usr/lib/python2.7/dist-packages/elbepack/commands/control.py", line 161, in run_command
>     action.execute(control, opt, args[1:])
>   File "/usr/lib/python2.7/dist-packages/elbepack/soapclient.py", line 444, in execute
>     client.download_file(builddir, filename, dst_fname)
>   File "/usr/lib/python2.7/dist-packages/elbepack/soapclient.py", line 89, in download_file
>     retry = retry - 1
> UnboundLocalError: local variable 'retry' referenced before assignment
> 
> Signed-off-by: John Ogness <john.ogness at linutronix.de>
> ---
>  elbepack/soapclient.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
> index fbb29a97..79f59a65 100644
> --- a/elbepack/soapclient.py
> +++ b/elbepack/soapclient.py
> @@ -81,12 +81,14 @@ class ElbeSoapClient(object):
>      def download_file(self, builddir, filename, dst_fname):
>          fp = file(dst_fname, "w")
>          part = 0
> +        retry = 2
>  
>          while True:
>              try:
>                  ret = self.service.get_file(builddir, filename, part)
>              except BadStatusLine as e:
>                  retry = retry - 1
> +                ret = "Exception"
>                  if not retry:
>                      fp.close()
>                      print("file transfer failed", file=sys.stderr)
> -- 
> 2.15.1
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel



More information about the elbe-devel mailing list