I have 3 functions. listener
function calls check_url
function in every 10 seconds. If this function success on checking, it calls destroy
function. After destroy
function done it's job, i want to terminate the listener
I tried to do it with finish_control
variable
def listener(url):
while True:
if finish_control == 1:
break
check_url(url)
sleep(10)
def check_url(url):
print ("Status: Listening")
response = urllib.request.urlopen(url)
data = response.read()
text = data.decode('utf-8')
if text == '1':
print("--Action Started!--")
destroy(argv.location)
def destroy(location):
#some work
print("---Action completed!---")
finish_control = 1
But the while loop inside listener
doesn't terminate. I also tried with
while (finish_control == 0):
There is also same problem. How can I make it stop after destroy
finishes it's job?