Measurement of delay between two signals using MSO4104 with PyVisa
Below is a script to measure delay in Ch1 - Ch2 raising edges with MDO4042 Tek scope.
I had to improvise to make delays between Ch1 and 2, so please tune the script to your needs.
#Script to measure delay with MDO4024C Mixed Domain Oscilloscope
import time
import pyvisa as visa
rm = visa.ResourceManager()
print('Available devices: ')
print(rm.list_resources())  #to check instruments connected
try:
    scope = rm.open_resource('USB0::0x0699::0x0456::C000197::INSTR', send_end = True)  #adding scope
    print('Device open: ', scope)
except:
    print('Opening device problem')

IDN = scope.query('*IDN?')
print ('Successfully connected to: ', IDN)

#---SCOPE SETUP---
scope.write(&quot;*RST&quot;)
scope.write('SELECT:CH1 ON')
print('Select Ch1: OK')

scope.write('SELECT:CH2 ON')
print('Select Ch2: OK')

scope.write('AUTOset EXECute')
print('Autoset: OK')

scope.write('HORizontal:SCAle 4E-3') #set horizontal scale to 4ms
print('Horizontal scale set to 4ms')

scope.write('TRIGger:A SETLevel') #set trigger level to 50% of range
print('Trigger to 50% of the range')

scope.write('MEASUrement:IMMed:DELay:DIRection FORWARDS')
print('Measurement type sent: OK')

scope.write('MEASure:DELay CH1,CH2')
print('Command sent: MEASure:DELay CH1,CH2')


scope.write('MEASurement:IMMed:TYPe DELay')
time.sleep(1)

#--checks to confirm---
#scope.write('MEASurement:IMMed:TYPe?')
#time.sleep(0.5)
#print(scope.read())
#-------
#time.sleep(2)
#scope.write('MEASurement:IMMed:DELay?')
#time.sleep(0.5)
#print(scope.read())
#-----------
#time.sleep(2)
#scope.write('MEASurement:IMMed:UNIts?')
#time.sleep(0.5)
#print(scope.read())
#-------

while True:
    scope.write('MEASurement:IMMed:VALue?')
    time.sleep(0.5)
    print(scope.read())

Commented part was used to confirm type of measurement, settings and units.
Below is a picture of returned values:

Two first received values shows some problems (scope manual say this specific value is normally associated with error), anyway later values are correct.