|
@@ -4,6 +4,7 @@
|
|
# @File : utils.py
|
|
# @File : utils.py
|
|
# @Software: PyCharm
|
|
# @Software: PyCharm
|
|
# @Python3.6
|
|
# @Python3.6
|
|
|
|
+import io
|
|
import uuid
|
|
import uuid
|
|
import math
|
|
import math
|
|
import time
|
|
import time
|
|
@@ -36,8 +37,9 @@ def release_lock(conn, lockname, identifier):
|
|
while True:
|
|
while True:
|
|
# try:
|
|
# try:
|
|
pipe.watch(lockname)
|
|
pipe.watch(lockname)
|
|
|
|
+ value = pipe.get(lockname)
|
|
# 判断标志是否相同
|
|
# 判断标志是否相同
|
|
- if pipe.get(lockname) is not None and str(pipe.get(lockname), encoding='utf-8') == identifier:
|
|
|
|
|
|
+ if value is not None and value.decode() == identifier:
|
|
pipe.multi()
|
|
pipe.multi()
|
|
pipe.delete(lockname)
|
|
pipe.delete(lockname)
|
|
pipe.execute()
|
|
pipe.execute()
|
|
@@ -57,4 +59,5 @@ def release_lock(conn, lockname, identifier):
|
|
# server = redis_client()
|
|
# server = redis_client()
|
|
# identifier = acquire_lock_with_timeout(server, 'dzr')
|
|
# identifier = acquire_lock_with_timeout(server, 'dzr')
|
|
# print(identifier)
|
|
# print(identifier)
|
|
-# release_lock(server, 'dzr', identifier)
|
|
|
|
|
|
+# identifier = '6ff8e107-0057-4510-95cc-2ac6f90c8501'
|
|
|
|
+# print(release_lock(server, 'dzr', identifier))
|