SEN0151 URM06 Pulse Ultrasonic Sensor With RaspberryPi

Hi,
I want to use my SEN0151 URM06 Pulse Ultrasonic Sensor with RaspberryPi 3B+.
However, I couldn't write a proper python code that would make the sensor work correctly.
With the code I wrote below, the sensor stops after about 3-5 minutes. I couldn't understand why.
<code>
import RPi.GPIO as GPIO
import time
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
TRIG = 23
ECHO = 24
GPIO.setup(TRIG,GPIO.OUT)
GPIO.setup(ECHO,GPIO.IN)
GPIO.output(TRIG, True)
while True:
time.sleep(2)
GPIO.setup(TRIG,GPIO.OUT)
GPIO.setup(ECHO,GPIO.IN)
GPIO.output(TRIG, False)
time.sleep(0.0005)
GPIO.output(TRIG, True)
time.sleep(0.0005)
GPIO.output(TRIG, False)
print ("dalga gonderildi")
pulse_start = 0
pulse_end = 0
while GPIO.input(ECHO)==0:
continue
pulse_start = time.time()
while GPIO.input(ECHO)==1:
continue
pulse_end = time.time()
print ("olculdu")
pulse_duration = pulse_end - pulse_start
mesafe = pulse_duration*100000
print(mesafe)
</code>
I would like your help for a RaspberryPi code similar to the example arduino application in the link below.
https://wiki.dfrobot.com/URM06-PULSE_Ultrasonic_SKU_SEN0151