Skip to content

Elethiomel/dynamodb-lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dynamodb-lock

dynamodb-lock is based on https://github.com/joeabrams026/dynamo-lock, a node.js and dynamodb based locking client. It supports autoexpiring locks, spinning for a lock and manually releasing a lock. It's designed primarily for use in AWS Lambda code, but can be used elsewhere without modification.

It needs better docs, exception handling and testing, but the guts are currently there. Patches welcome!

Usage

lock = Lockerclient('mylocktable')

If necessary, create the lock table.

lock.create_lock_table()

Attempt to aquire a lock. Returns True or False if succeeded.

timeout = 1000  # 1000 milliseconds is one second
lock.get_lock('mylock', timeout)

Alternatively, spin for a lock if locks are bound to be short lived and you can spare the cpu.

lock.spinlock('mylock', 10)

Finally, release your lock

lock.release_lock('mylock', 10)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages