From 65c4df27d29e65a3ab0a286085a998a3ecda6dfc Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Mon, 12 Oct 2020 21:20:27 +0000 Subject: [PATCH] Fix search errors due to stream readers exiting before grep is finished --- irclog.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/irclog.py b/irclog.py index c4897db..76cc8d6 100644 --- a/irclog.py +++ b/irclog.py @@ -1040,6 +1040,8 @@ class WebServer: stdoutTask = asyncio.create_task(process_stdout()) stderrTask = asyncio.create_task(process_stderr()) await asyncio.wait({stdoutTask, stderrTask}, timeout = self.config['web']['search']['maxTime']) + # The stream readers may quit before the process is done even on a successful grep. Wait a tiny bit longer for the process to exit. + await asyncio.wait({asyncio.create_task(proc.wait())}, timeout = 0.1) if proc.returncode is None: # Process hasn't finished yet after maxTime. Murder it and wait for it to die. self.logger.warning(f'Request {id(request)} grep took more than the time limit')