allisonkarlitskaya / cimg

1 stars 0 forks source link

'error' is reported as status in two different places in image downloader #8

Open allisonkarlitskaya opened 4 years ago

allisonkarlitskaya commented 4 years ago

The worker threads in the image_download.py report statuses (progress, error, etc.) back to the main thread at various points. At the start, error is taken to mean that the mirror can't be contacted for some reason (and the thread is dropped from the list of threads that we're waiting for initial results from).

Later on, though, while downloading, a timeout exception will also be caught and reported as an error:

    except urllib3.exceptions.MaxRetryError as e:
        status_queue.put((prefix, 'error', e.reason))

which causes an exception in the main thread:

Traceback (most recent call last):
  File "/var/home/lis/.local/bin/cimg", line 199, in <module>
    sys.exit(main())
  File "/var/home/lis/.local/bin/cimg", line 194, in main
    args.func(args, None)
  File "/var/home/lis/.local/bin/cimg", line 150, in cmd_download
    image_download.get_image(image.filename)
  File "/var/home/lis/src/cimg/image_download.py", line 422, in get_image
    download(destination, prefixes, path, ui)
  File "/var/home/lis/src/cimg/image_download.py", line 175, in download
    todo.remove(prefix)
KeyError: 'https://images-frontdoor.apps.ocp.ci.centos.org/'

This needs to be handled better: there should be a way to quit the download process, after it has started, without having successfully downloaded the complete file.

It might also be interesting if threads didn't immediately quit on error, but stuck around to retry later (as long as other threads were still making progress).