Fixed race condition referring to self when operator may have stopped running
The `file_loading` function is called deferred by asyncio, and can thus be called when the operator has already stopped loading. This is fixed by not referring to `self` in that function, and taking the logger from the outer scope.
This commit is contained in:
parent
974d33e3a3
commit
ff9ae0117d
@ -707,18 +707,19 @@ class PILLAR_OT_switch_hdri(pillar.PillarOperatorMixin,
|
|||||||
resolution = next(file_ref['resolution'] for file_ref in node['properties']['files']
|
resolution = next(file_ref['resolution'] for file_ref in node['properties']['files']
|
||||||
if file_ref['file'] == file_uuid)
|
if file_ref['file'] == file_uuid)
|
||||||
|
|
||||||
self.log.info('Downloading file %r-%s to %s', file_uuid, resolution, local_path)
|
my_log = self.log
|
||||||
self.log.debug('Metadata will be stored at %s', meta_path)
|
my_log.info('Downloading file %r-%s to %s', file_uuid, resolution, local_path)
|
||||||
|
my_log.debug('Metadata will be stored at %s', meta_path)
|
||||||
|
|
||||||
def file_loading(file_path, file_desc, map_type):
|
def file_loading(file_path, file_desc, map_type):
|
||||||
self.log.info('Texture downloading to %s (%s)',
|
my_log.info('Texture downloading to %s (%s)',
|
||||||
file_path, utils.sizeof_fmt(file_desc['length']))
|
file_path, utils.sizeof_fmt(file_desc['length']))
|
||||||
|
|
||||||
async def file_loaded(file_path, file_desc, map_type):
|
async def file_loaded(file_path, file_desc, map_type):
|
||||||
if context.scene.local_texture_dir.startswith('//'):
|
if context.scene.local_texture_dir.startswith('//'):
|
||||||
file_path = bpy.path.relpath(file_path)
|
file_path = bpy.path.relpath(file_path)
|
||||||
|
|
||||||
self.log.info('Texture downloaded to %s', file_path)
|
my_log.info('Texture downloaded to %s', file_path)
|
||||||
current_image['bcloud_file_uuid'] = file_uuid
|
current_image['bcloud_file_uuid'] = file_uuid
|
||||||
current_image.filepath = file_path # This automatically reloads the image from disk.
|
current_image.filepath = file_path # This automatically reloads the image from disk.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user