From db10201cd3324c818f507a042a83c8d73263ad68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 22 Mar 2016 11:30:00 +0100 Subject: [PATCH] Faster cancelling of thumbnail downloads. I forgot to pass the 'future' object to the download_texture_thumbnail function, and as such it wasn't notified of cancellations. --- blender_cloud/pillar.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blender_cloud/pillar.py b/blender_cloud/pillar.py index 1404fcb..a1d6422 100644 --- a/blender_cloud/pillar.py +++ b/blender_cloud/pillar.py @@ -185,6 +185,9 @@ async def download_to_file(url, filename, *, except KeyError: pass + if is_cancelled(future): + log.debug('Downloading was cancelled before doing the GET.') + raise asyncio.CancelledError('Downloading was cancelled') return uncached_session.get(url, headers=headers, stream=True, verify=True) # Download the file in a different thread. @@ -302,7 +305,8 @@ async def fetch_texture_thumbs(parent_node_uuid: str, desired_size: str, coros = (download_texture_thumbnail(texture_node, desired_size, thumbnail_directory, thumbnail_loading=thumbnail_loading, - thumbnail_loaded=thumbnail_loaded) + thumbnail_loaded=thumbnail_loaded, + future=future) for texture_node in chunk) # raises any exception from failed handle_texture_node() calls.