Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge commit '0a86850ba' into anoa/dinsic_release_1_21_x
Browse files Browse the repository at this point in the history
* commit '0a86850ba':
  Stop the parent process flushing the logs on exit (#8012)
  • Loading branch information
anoadragon453 committed Oct 16, 2020
2 parents 78aa8df + 0a86850 commit 4d4770d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/8011.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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.
1 change: 0 additions & 1 deletion changelog.d/8011.misc

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/8012.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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.
10 changes: 8 additions & 2 deletions synapse/util/daemonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 4d4770d

Please sign in to comment.