MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / acquire

Method acquire

dispatcharr/persistent_lock.py:33–43  ·  view source on GitHub ↗

Attempt to acquire the lock. Returns True if successful.

(self)

Source from the content-addressed store, hash-verified

31 return self.has_lock
32
33 def acquire(self) -> bool:
34 """
35 Attempt to acquire the lock. Returns True if successful.
36 """
37 self.lock_token = str(uuid.uuid4())
38 # Set the lock with NX (only if not exists) and EX (expire time)
39 result = self.redis_client.set(self.lock_key, self.lock_token, nx=True, ex=self.lock_timeout)
40 if result is not None:
41 self.has_lock = True
42
43 return result is not None
44
45 def refresh(self) -> bool:
46 """

Callers 3

stream_viewFunction · 0.95
persistent_lock.pyFile · 0.80

Calls 1

setMethod · 0.45

Tested by

no test coverage detected