Verified Commit 3bbed760 authored by Martin Petráček's avatar Martin Petráček
Browse files

handler & show: change makefile() usage on socket

parent 7ac33776
......@@ -163,7 +163,8 @@ def query(query):
class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
def handle(self):
data = self.request.makefile().readline().strip()
with self.request.makefile() as f:
data = f.readline().strip()
self.request.sendall((query(data)+"\n").encode())
def main():
......
......@@ -122,7 +122,8 @@ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
sock.connect("/var/run/pakon-query.sock")
sock.sendall((query+"\n").encode())
response = sock.makefile().readline().strip()
with sock.makefile() as f:
response = f.readline().strip()
except:
print("Can't get data from pakon-handler. Is it running?")
sys.exit(1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment