-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblackboard.py
More file actions
41 lines (34 loc) · 1.16 KB
/
blackboard.py
File metadata and controls
41 lines (34 loc) · 1.16 KB
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
import threading
class Blackboard:
def __init__(self, goal):
self._lock = threading.Lock()
self._data = {
"goal": goal,
"srs": "",
"architecture": "",
"backend_code": "",
"frontend_code": "",
"frontend_feedback": "",
"backend_feedback": "",
"frontend_review_passed": False,
"backend_review_passed": False,
"frontend_needed": True,
"backend_needed": True,
}
def get(self, key, default=None):
with self._lock:
return self._data.get(key, default)
def set(self, key, value):
with self._lock:
self._data[key] = value
def append_to(self, key, item):
with self._lock:
if key in self._data and isinstance(self._data[key], list):
self._data[key].append(item)
def get_all(self):
with self._lock:
return dict(self._data)
def clear(self, key):
with self._lock:
if key in self._data:
self._data[key] = [] if isinstance(self._data[key], list) else ""