Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
☭ ~ $ revel new src/sweet_app | |
☭ ~ $ cd src/sweet_app/ | |
☭ ~/sweet_app $ git init | |
☭ ~/sweet_app (master)$ cat > .godir | |
sweet_app | |
^C | |
☭ ~/sweet_app (master)$ git add .godir * | |
☭ ~/sweet_app (master)$ git ci -m"Initial" | |
☭ ~/sweet_app (master)$ heroku create --buildpack https://github.com/traviscline/heroku-buildpack-go-revel.git | |
☭ ~/sweet_app (master)$ git push heroku master |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
def acquire(name): | |
tries = 0 | |
while True: | |
tries += 1 | |
if tries >= 30: | |
raise Exception("Couldn't acquire lock on mutex "+name) | |
try: | |
n = r.incr("lock-"+name) | |
if n == 1: | |
return True |