diff --git a/blender_cloud/async_loop.py b/blender_cloud/async_loop.py index 7db5f6e..a7395d4 100644 --- a/blender_cloud/async_loop.py +++ b/blender_cloud/async_loop.py @@ -94,7 +94,6 @@ def erase_async_loop(): loop = asyncio.get_event_loop() loop.stop() - _loop_kicking_operator_running = False class AsyncLoopModalOperator(bpy.types.Operator): @@ -104,6 +103,14 @@ class AsyncLoopModalOperator(bpy.types.Operator): timer = None log = logging.getLogger(__name__ + '.AsyncLoopModalOperator') + def __del__(self): + global _loop_kicking_operator_running + + # This can be required when the operator is running while Blender + # (re)loads a file. The operator then doesn't get the chance to + # finish the async tasks, hence stop_after_this_kick is never True. + _loop_kicking_operator_running = False + def execute(self, context): return self.invoke(context, None)