Skip to content
Snippets Groups Projects
Commit 153297b7 authored by Della Baby's avatar Della Baby
Browse files

changes for lab1

parent 29724326
Branches master
No related tags found
No related merge requests found
......@@ -68,19 +68,20 @@ class DatabaseProxy(object):
#
# Your code here.
#
args = []
msg = {
"method": "read" ,
"args": args
"args": []
}
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(self.address)
conn = s.makefile(mode="rw")
conn.write(json.dumps(msg) + '\n')
conn.flush()
res = json.loads(conn.readline())
conn.flush()
worker = s.makefile(mode="rw")
worker.write(json.dumps(msg) + '\n')
worker.flush()
res = json.loads(worker.readline())
s.close()
return res
pass
......@@ -94,12 +95,14 @@ class DatabaseProxy(object):
}
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(self.address)
conn = s.makefile(mode="rw")
conn.write(json.dumps(msg) + '\n')
conn.flush()
res = json.loads(conn.readline())
conn.flush()
worker = s.makefile(mode="rw")
worker.write(json.dumps(msg) + '\n')
worker.flush()
res = json.loads(worker.readline())
s.close()
if res:
print(res)
pass
......
......@@ -3017,39 +3017,3 @@ come at you rapidly.
"Style Invitational Report from Week 278" published
August 2, 1998
%
TDDD25
%
distributed systems
%
hai
%
hai
%
hai
%
jhj
%
jkjkj
%
nnn
%
jjj
%
hhh
%
jkdhkjhdf
%
iudyucgdhcn
%
ttttttttttttt
%
jjjjjjjjjjj
%
kkkkkkkkk
%
hhhh
%
jj
%
klooo
%
......@@ -129,16 +129,23 @@ class Request(threading.Thread):
#
request_message = json.loads(request)
try:
#print(request_message)
if request_message != None and request_message['method'] != None and request_message['args'] != None:
if request_message['method'] == "write" and len(request_message['args']) > 0:
res = json.dumps(self.db_server.write(request_message['args']))
elif request_message['method'] == "read":
res = json.dumps(self.db_server.read())
except Exception as e:
else:
res = json.dumps({"error" : {"name": "Unknown method" , "args": request_message['method']}})
#res = json.dumps({"error" : {"name": "error method" , "args": request_message['method']}})
else:
res = json.dumps({"error" : {"name": "Unknown method" , "args": request_message['method']}})
#res = json.dumps({"error" : {"name": "error method" , "args": request_message['method']}})
return res
pass
def run(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment