searcher - updated timings

This commit is contained in:
2022-10-04 22:58:27 -05:00
parent 0dece2cec9
commit e929e9b742
7 changed files with 75 additions and 71 deletions

View File

@@ -48,47 +48,32 @@ class IPCServer:
self.is_ipc_alive = True
while True:
conn = listener.accept()
start_time = time.perf_counter()
self.handle_message(conn, start_time)
conn = listener.accept()
if not self.pause_fifo_update:
self.handle_message(conn)
else:
conn.close()
listener.close()
def handle_message(self, conn, start_time) -> None:
def handle_message(self, conn) -> None:
while True:
msg = conn.recv()
if not self.pause_fifo_update:
if "SEARCH|" in msg:
file = msg.split("SEARCH|")[1].strip()
if file:
GLib.idle_add(self._load_file_ui, file)
if "SEARCH|" in msg:
file = msg.split("SEARCH|")[1].strip()
if file:
GLib.idle_add(self._load_file_ui, file)
conn.close()
break
if "GREP|" in msg:
data = msg.split("GREP|")[1].strip()
if data:
GLib.idle_add(self._load_grep_ui, data)
conn.close()
break
if "GREP|" in msg:
data = msg.split("GREP|")[1].strip()
if data:
GLib.idle_add(self._load_grep_ui, data)
if msg in ['close connection', 'close server']:
conn.close()
break
# NOTE: Not perfect but insures we don't lock up the connection for too long.
end_time = time.perf_counter()
if (end_time - start_time) > self._ipc_timeout:
conn.close()
break
else:
conn.close()
break
conn.close()
break
def send_ipc_message(self, message: str = "Empty Data...") -> None:
try:

View File

@@ -33,15 +33,11 @@ def daemon_threaded(fn):
def send_ipc_message(message) -> None:
try:
conn = Client(address=_ipc_address, family="AF_UNIX", authkey=_ipc_authkey)
with Client(address=_ipc_address, family="AF_UNIX", authkey=_ipc_authkey) as conn:
conn.send(message)
conn.close()
except ConnectionRefusedError as e:
print("Connection refused...")
except Exception as e:
print(repr(e))
time.sleep(0.05)
def file_search(path, query):