« first day (2352 days earlier)      last day (1004 days later) » 

1:00 PM
self.lock = threading.Lock()

while application_is_running():
    if self.lock.locked():
        # second lock check to prevent runtime exception where the lock is released inbetween the two if statements
        if some_condition and self.lock.locked():
            # cancel previous thread
            self.lock.release()
            # sleep shortly to make sure the acquire call in the thread get's the lock and not the below acquire call
            time.sleep(0.001)
            # acquire lock here so that the acquire call in the thread can act as an abortable sleep. Either it finishes or i
 
1 message moved from Python
 

« first day (2352 days earlier)      last day (1004 days later) »