Skip to content
Snippets Groups Projects
Unverified Commit 0a86850b authored by Richard van der Hoff's avatar Richard van der Hoff Committed by GitHub
Browse files

Stop the parent process flushing the logs on exit (#8012)

This solves the problem that the first few lines are logged twice on matrix.org. Hopefully the comments explain it.
parent 8b786db3
No related branches found
No related tags found
No related merge requests found
Fix a long-standing bug which caused two copies of some log lines to be written when synctl was used along with a MemoryHandler logger.
Replace daemonize library with a local implementation.
Fix a long-standing bug which caused two copies of some log lines to be written when synctl was used along with a MemoryHandler logger.
......@@ -60,8 +60,14 @@ def daemonize_process(pid_file: str, logger: logging.Logger, chdir: str = "/") -
process_id = os.fork()
if process_id != 0:
# parent process
sys.exit(0)
# parent process: exit.
# we use os._exit to avoid running the atexit handlers. In particular, that
# means we don't flush the logs. This is important because if we are using
# a MemoryHandler, we could have logs buffered which are now buffered in both
# the main and the child process, so if we let the main process flush the logs,
# we'll get two copies.
os._exit(0)
# This is the child process. Continue.
......
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