How to update compositing nodes via script? I create some nodes in compositing via python script:

dbl_info = { 
   "name": "Tmp Addon",
   "category": "All" 
}
import bpy
class tmpAddon(bpy.types.Operator):
   bl_idname = "tmp.tmp_addon"
   bl_label = "tmpAddon"
   bl_options = {"REGISTER", "UNDO"}

def execute(self, context):
    if not bpy.context.scene.use_nodes:
        bpy.context.scene.use_nodes = True
    nodesField = bpy.context.scene.node_tree
    for currentNode in nodesField.nodes:
        nodesField.nodes.remove(currentNode)
    bpy.ops.image.open(filepath="d:/Blender/_TMP/Addon_tmp/p_1.png", directory = "d:/Blender/_TMP/Addon_tmp/")
    currentImageNode = nodesField.nodes.new(type = 'CompositorNodeImage')
    currentImageNode.image = bpy.data.images['p_1.png']
    currentImageNode.location = (0, 0)
    currentImageNode.name = 'p_1.png'
    currentOutputNode = nodesField.nodes.new(type = 'CompositorNodeComposite')
    currentOutputNode.location = (200, 0)
    nodesField.links.new(nodesField.nodes['p_1.png'].outputs['Image'], currentOutputNode.inputs['Image'])
    return {'FINISHED'}

def register():
    bpy.utils.register_class(tmpAddon)
def unregister():
    bpy.utils.unregister_class(tmpAddon)
if __name__ == "__main__":
    register()
    bpy.ops.tmp.tmp_addon()d


It works, but after executions created nodes are inactive:



after any manipulations (for example uncheck "Use Alpha" checkbox on Output node) all of nodes updates and become active



I found that if there is an opened window with compositing nodes during script execution, generated nodes updates, and work fine. But if there is no compositing nodes window during script run, nodes stay not updated after script execution.

How can I update compositing nodes via script and force them to work if there is no active compositing window during script execution?
Did you try to activate the composite node like this:

scene = bpy.context.scene
scene.node_tree.nodes.active = scene.node_tree.nodes['Your composite node']
scene.render.use_compositing = True