Unable to render Movie Render Queue PIE Executor from commandline Python script

We have a custom MoviePipelineExecutor derived from UMoviePipelinePIEExecutor to manipulate some data layer membership before rendering. This executor requires the editor so I can’t use any of the CLI rendering examples that all use “-game”.

I am able to call a Python script with -ExecutePythonScript

UnrealEditor-Cmd.exe %PROJECT_NAME% %MAP_NAME% -ExecutePythonScript=

My Python script sets up the queue and the job and renders the queue with:

`def render_sequence(sequence: Union[str, unreal.LevelSequence], config: Union[str, unreal.MoviePipelinePrimaryConfig]):
if isinstance(sequence, str):
path = unreal.TopLevelAssetPath(“/Script/LevelSequence”, “LevelSequence”)
sequence = get_asset_by_name(sequence, path)
if isinstance(config, str):
path = unreal.TopLevelAssetPath(“/Script/MovieRenderPipelineCore”, “MoviePipelinePrimaryConfig”)
config = get_asset_by_name(config, path)

subsystem = unreal.get_editor_subsystem(unreal.MoviePipelineQueueSubsystem)
queue = subsystem.get_queue()
job = unreal.MoviePipelineEditorLibrary.create_job_from_sequence(pipeline_queue=queue, sequence=sequence)
job.set_configuration(config)

subsystem.render_queue_with_executor_instance(executor)`

However, the call render_queue_with_executor_instance seems to be a non-blocking call and launches in another process, so the host editor process finishes executing the Python script and closes the editor before the rendering process is finished.

Is there a way I can render with a blocking call so it waits until it is done rendering before closing the editor?

Looks like I can use

unreal.EditorPythonScripting.set_keep_python_script_alive(True)and then set to False in the on_executor_finished_delegate

Great! Glad you were able to address it.