Is there any sane way to pass task frame number to Nuke script job?

I just want to execute python inside Nuke and then save the current task’s frame manually.
nuke.execute(nuke.toNode("Write1"), start, end)

I edited the official Nuke plugin, changed this:

def RenderTasks( self ):
        
        if self.BatchMode and self.ScriptJob:
            scriptFileName = self.GetPluginInfoEntry( "ScriptFilename" ).replace( "\\", "/" )

            self.WritePython( f"exec(open('{scriptFileName}').read(), globals(), locals())" )

to this:

def RenderTasks( self ):
        
        if self.BatchMode and self.ScriptJob:
            scriptFileName = self.GetPluginInfoEntry( "ScriptFilename" ).replace( "\\", "/" )
            self.WritePython("DEADLINE_START_FRAME = %d" % self.GetStartFrame())
            self.WritePython("DEADLINE_END_FRAME   = %d" % self.GetEndFrame())
            self.WritePython( f"exec(open('{scriptFileName}').read(), globals(), locals())" )

And my script can now use those variables:

nuke.execute(nuke.toNode("Write2"), DEADLINE_START_FRAME, DEADLINE_END_FRAME)