add hack code

This commit is contained in:
Nico Schottelius 2020-01-15 10:02:37 +01:00
commit b877ab13b3
2 changed files with 23 additions and 6 deletions

View file

@ -86,10 +86,23 @@ class DB(object):
return self._db_clients[0].put(self.realkey(key), value, **kwargs)
@readable_errors
def increment(key, **kwargs):
with self._db_clients[0].lock(key) as lock:
value = int(self.get(self.realkey(key), **kwargs))
self.set(self.realkey(key), str(value + 1), **kwargs)
def increment(self, key, **kwargs):
print(self.realkey(key))
print("prelock")
lock = self._db_clients[0].lock('/nicohack/foo')
print("prelockacq")
lock.acquire()
print("prelockrelease")
lock.release()
with self._db_clients[0].lock("/nicohack/mac/last_used_index") as lock:
print("in lock")
pass
# with self._db_clients[0].lock(self.realkey(key)) as lock:# value = int(self.get(self.realkey(key), **kwargs))
# self.set(self.realkey(key), str(value + 1), **kwargs)
if __name__ == '__main__':