diff options
author | Anthony Wang | 2024-07-27 22:41:36 +0000 |
---|---|---|
committer | Anthony Wang | 2024-07-27 22:41:36 +0000 |
commit | e452bb52fc2f34a8b26c993cb5049f4db49661d3 (patch) | |
tree | 17f98f61089cc6d5a53008b63d779c1ff8b05054 /client.py | |
parent | 6cfff24189ffce3b239c1af2cb744a26a07b9177 (diff) |
Use with to ensure locks released, RPC over Unix socket instead of TCP, start watches ASAP instead of after indexing is done
Diffstat (limited to 'client.py')
-rw-r--r-- | client.py | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -1,8 +1,28 @@ +from http.client import HTTPConnection import os +import socket import sys import xmlrpc.client -proxy = xmlrpc.client.ServerProxy(f"http://localhost:{os.environ.get("PORT", 8000)}") + +class UnixStreamHTTPConnection(HTTPConnection): + def connect(self): + self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self.sock.connect(self.host) + + +class UnixStreamTransport(xmlrpc.client.Transport, object): + def __init__(self, socket_path): + self.socket_path = socket_path + super().__init__() + + def make_connection(self, host): + return UnixStreamHTTPConnection(self.socket_path) + + +proxy = xmlrpc.client.ServerProxy( + "http://localhost", transport=UnixStreamTransport("search.sock") +) res = proxy.search(sys.argv[1], sys.argv[2]) print("\n".join(res)) |