I am developing a Linux-based application, but right now I am faced with the fact that I need to call a web browser to perform a further task, but the problem is that the program is stuck and does not end. I tried to finish it with a thread, but it does not receive an interrupt, and the thread runs endlessly, below is the basic version of the code I tried. Hope you got my problem,
import time
import threading
import webbrowser
class CountdownTask:
def __init__(self):
self._running = True
def terminate(self):
self._running = False
def run(self):
url='http://www.google.com'
webbrowser.open(url,new=1)
c = CountdownTask()
t = threading.Thread(target=c.run)
t.start()
time.sleep(1)
c.terminate()
t.join()
source
share