Last active
December 15, 2016 01:39
-
-
Save Lucretiel/4c7026ec9831f4203dedd8e38dd3404b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SyncClientThread: | |
def __init__(self): | |
... | |
self.stop = False | |
self.nostop_depth = 0 | |
def Stop(self): | |
self.stop = True | |
def IsStopped(self): | |
return self.nostop_depth == 0 and self.stop | |
def RaiseIfStopped(self): | |
if self.stopped: | |
raise StopError | |
@contextlib.contextmanager | |
def NoStop(self): | |
self.nostop_depth += 1 | |
try: | |
yield | |
finally: | |
self.nostop_depth -= 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment