Forgive me if this is a dumb question; I am very new to threading.
I am running a thread that will finish when I change it’s keeprunning status like so:
class mem_mon(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.keeprunning = True
self.maxmem = 0
def run(self):
while self.keeprunning:
self.maxmem = max(self.maxmem, ck_mem())
time.sleep(10)
But due to the sleep call, I often have to wait a while before they join. Other than creating a faster loop that checks keeprunning more often, is there anything I can do to join the thread more instantaneously? For example by overriding __del__ or join?
Use threading.Event as an time.sleep() you can interrupt.