fix exam 考试
This commit is contained in:
parent
37621e170b
commit
967f116c72
|
@ -54,6 +54,18 @@ def dectry(p):
|
|||
dec_str = dec_str+temp
|
||||
return dec_str
|
||||
|
||||
def acquire_lock(lock_name, timeout=60):
|
||||
identifier = str(uuid.uuid4())
|
||||
lock = cache.set(lock_name, identifier, timeout=timeout)
|
||||
print(lock, identifier)
|
||||
return identifier if lock else None
|
||||
|
||||
def release_lock(lock_name, identifier):
|
||||
if cache.get(lock_name) == identifier:
|
||||
cache.delete(lock_name)
|
||||
return True
|
||||
else:
|
||||
raise ParseError('Lock identifier does not match')
|
||||
|
||||
class QuestioncatViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
||||
perms_map = {'get': '*', 'post':'question', 'put':'question', 'delete':'question'}
|
||||
|
@ -691,7 +703,7 @@ class ExamRecordViewSet(ListModelMixin, DestroyModelMixin, RetrieveModelMixin, G
|
|||
# 获取锁
|
||||
iden = acquire_lock('certificate')
|
||||
if iden is None:
|
||||
raise ParseError("系统忙, 请稍后再试")
|
||||
raise ParseError("系统忙, 请稍后再试........")
|
||||
try:
|
||||
# 查询证明编号创建时间为最后一个
|
||||
cer = Certificate.objects.latest('证书编号')
|
||||
|
@ -728,15 +740,3 @@ class ExamRecordViewSet(ListModelMixin, DestroyModelMixin, RetrieveModelMixin, G
|
|||
return Response(ExamRecordListSerializer(instance=er).data)
|
||||
|
||||
|
||||
def acquire_lock(lock_name, timeout=60):
|
||||
identifier = str(uuid.uuid4())
|
||||
lock = cache.set(lock_name, identifier, timeout=timeout)
|
||||
print(lock, identifier)
|
||||
return identifier if lock else None
|
||||
|
||||
def release_lock(lock_name, identifier):
|
||||
if cache.get(lock_name) == identifier:
|
||||
cache.delete(lock_name)
|
||||
return True
|
||||
else:
|
||||
raise ParseError('Lock identifier does not match')
|
Loading…
Reference in New Issue