call task_done() anyway

This commit is contained in:
Yuxiang Zhang 2020-02-18 11:46:11 +08:00 committed by GitHub
parent 905940b302
commit 063b349ea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
import os
import threading
import queue
import traceback
from pathlib import Path
from email.utils import parsedate_to_datetime
@ -98,6 +99,7 @@ def downloading_worker(q):
if item is None:
break
try:
url, dst_file, working_dir = item
if dst_file.is_file():
print("checking", url, flush=True)
@ -110,19 +112,17 @@ def downloading_worker(q):
if remote_filesize == local_filesize and remote_date.timestamp() == local_mtime:
print("skipping", dst_file.relative_to(working_dir), flush=True)
q.task_done()
continue
dst_file.unlink()
print("downloading", url, flush=True)
try:
requests_download(url, dst_file)
except Exception:
traceback.print_exc()
print("Failed to download", url, flush=True)
if dst_file.is_file():
dst_file.unlink()
finally:
q.task_done()