Skip to content

Commit e76574e

Browse files
authored
Merge pull request #1 from Sensibo/master
Bugfix: do not wait 30 seconds for expiry, trust the ttl
2 parents be57d31 + 78c05cb commit e76574e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

python_dynamodb_lock/python_dynamodb_lock.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,8 @@ def acquire_lock(self,
448448
last_record_version_number)
449449
# if the record_version_number has not changed for more than _lease_duration period,
450450
# it basically means that the owner thread/process has died.
451-
last_version_elapsed_time = time.monotonic() - last_version_fetch_time
452-
if last_version_elapsed_time > existing_lock.lease_duration:
453-
logger.warning('Existing lock\'s lease has expired: %s', str(existing_lock))
451+
if existing_lock.expiry_time < time.time():
452+
logger.warning('Existing lock\'s lease has expired: %s (%s)', str(existing_lock), time.time())
454453
self._overwrite_existing_lock_in_dynamodb(new_lock, last_record_version_number)
455454
logger.debug('Added to the DDB. Adding to in-memory map: %s', new_lock.unique_identifier)
456455
new_lock.status = DynamoDBLock.LOCKED

0 commit comments

Comments
 (0)