def test_spawn_locked(self): l = RLock() def set_v1(): with l: self.v = 1 # check our setter works in isolation assert self.v is None self.do_spawn(set_v1).wait() assert self.v == 1 # now do a long running task works with l: self.v = 2 assert self.v == 2 # start our thing that will be blocked, then sleep to make sure # it can't do its thing s = self.do_spawn(set_v1) sleep(0.2) assert self.v == 2 # now wait for the other to complete, and check it could s.wait() assert self.v == 1
def __init__(self, controller: Controller, field: str = None) -> None: self.controller = controller # Lock to control access to self.pv self._lock = RLock() self.field = field self.pv: Optional[SharedPV] = None self.value: Value = None self.put_paths: Set[str] = set()
def __init__(self, controller, field=None): # type: (Controller, str) -> None self.controller = controller # Lock to control access to self.pv self._lock = RLock() self.field = field self.pv = None # type: Optional[SharedPV] self.value = None # type: Value self.put_paths = None # type: Set[str]
def test_spawn_unlocked(self): l = RLock() def set_v1(): self.v = 1 # check our setter works in isolation self.do_spawn(set_v1).wait() assert self.v == 1 # now do a long running task works with l: self.v = 2 assert self.v == 2 self.do_spawn(set_v1).wait() assert self.v == 1 assert self.v == 1