How to wait the finish of the bpy.ops.render.render('INVOKE_DEFAULT',animation=False, write_still=True)? What interests me is basically to stop the execution of my code until the end of the render but at the same time view the progress of the render, considering that the possibility of the "ESC" key that cancels the render.
I am looking on the internet but the situation is unclear to me, I found this:

Is it possible to make a sequence of renders and give the user the option to cancel the process through the UI at any given time?

but it seems quite complicated, I was wondering if there was a simpler solution to my specific case, as my situation is slightly different, as I don't want to render multiple.

Practically:

    ## my code
    ## my code
    bpy.ops.render.render ('INVOKE_DEFAULT', animation = False, write_still = True)
    ## if render is done:
    ###### my code
    ###### my code
Blender's API documentation shows how to use the application handlers. In order to execute a function after rendering is complete, you can use one of the following two handlers: 


bpy.app.handlers.render_post - Executed once after each rendered frame
bpy.app.handlers.render_complete - Executed once after all frames have been rendered


The function you want to execute is appended to the list of handler functions through append(some_function), where some_function is a reference to a function. It needs to take one argument, because an object of bpy.types.Scene will be passed to the function. Example:

def some_function(dummy):
    print("some function")

bpy.app.handlers.render_post.append(some_function)


If you later want to remove the function from the list of handlers, simply use remove(some_function). Example:

bpy.app.handlers.render_post.remove(some_function)




import bpy

def some_function(dummy):
    print("some function")

def some_other_function(dummy):
    print("some other function")

# Will be executed once after each rendered frame
bpy.app.handlers.render_post.append(some_function)

# Will be executed once when the whole rendering process is completed
bpy.app.handlers.render_complete.append(some_other_function)

bpy.ops.render.render('INVOKE_DEFAULT', write_still = True)