-
Notifications
You must be signed in to change notification settings - Fork 1
/
question.py
47 lines (38 loc) · 1.05 KB
/
question.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import threading
class Question:
def __init__(self, uuid, data, votes=0, answer=None, author="AI", is_student=False):
self.uuid = uuid
self.data = data
self.votes = votes
self.mut = threading.Lock()
self.answer = answer
self.author = author
self.is_student = is_student
def votes_increment(self):
self.mut.acquire()
self.votes += 1
self.mut.release()
def votes_decrement(self):
self.mut.acquire()
self.votes -= 1
self.mut.release()
def get_data(self):
self.mut.acquire()
data = self.data
self.mut.release()
return data
def get_uuid(self):
self.mut.acquire()
uuid = self.uuid
self.mut.release()
return uuid
def get_answer(self):
self.mut.acquire()
answer = self.answer
self.mut.release()
return answer
def get_votes(self):
self.mut.acquire()
answer = self.votes
self.mut.release()
return answer