示例#1
0
 def acquire_shared(self, shared_lock: SharedLock) -> bool: # respects wall-time timeout, see issue9892
     if self.infinite:
         return shared_lock.acquire_shared()
     remain = self.remain # there is no special handling for case remain == 0.0, because that
     while remain > 0.0:  # would mean request deadline hence performance is no longer an issue
         if shared_lock.acquire_shared(remain):
             return True
         remain = self.remain
     else:
         return False
示例#2
0
 def acquire_shared(
     self, shared_lock: SharedLock
 ) -> bool:  # respects wall-time timeout, see issue9892
     if self.infinite:
         return shared_lock.acquire_shared()
     remain = self.remain  # there is no special handling for case remain == 0.0, because that
     while remain > 0.0:  # would mean request deadline hence performance is no longer an issue
         if shared_lock.acquire_shared(remain):
             return True
         remain = self.remain
     else:
         return False
示例#3
0
 def acquire_shared_fast(self, shared_lock: SharedLock) -> bool: # respects wall-time timeout, see issue9892
     if shared_lock.acquire_shared(0.0): # shared lock accepts zero timeout
         return True
     return self.acquire_shared(shared_lock)
示例#4
0
 def acquire_shared_fast(
     self, shared_lock: SharedLock
 ) -> bool:  # respects wall-time timeout, see issue9892
     if shared_lock.acquire_shared(0.0):  # shared lock accepts zero timeout
         return True
     return self.acquire_shared(shared_lock)