summaryrefslogtreecommitdiff
path: root/tools/edit_monitor/main.py
diff options
context:
space:
mode:
author Zhuoyao Zhang <zhuoyao@google.com> 2024-12-04 17:39:54 +0000
committer Zhuoyao Zhang <zhuoyao@google.com> 2024-12-04 21:09:44 +0000
commita7107913d9ed38b23d140fe29eef1ff374663902 (patch)
tree603c7aa29ff5ce6a91989a8a7875d873bb19bf65 /tools/edit_monitor/main.py
parent3b2cf40ee8595d3cc88b66a86dede83e56228a8d (diff)
Fix a race condition in edit monitor
When there are multiple edit monitor starting around the same time, there will be cases that the pidfile is deleted or overridden as multiple processes are trying to remove and create the pidfile around the same time (see details in b/382135550). This cl fix it by checking the pid in the pidfile and only remove the pidfile if the pid stored there is the expected one. Bug: 382135550 Test: atest edit_monitor_integration_test Change-Id: Ifdb4c29c8b36052fea83ce59de1be9d99db3a852
Diffstat (limited to 'tools/edit_monitor/main.py')
-rw-r--r--tools/edit_monitor/main.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/edit_monitor/main.py b/tools/edit_monitor/main.py
index 49385f1cc5..7ca0daa7c5 100644
--- a/tools/edit_monitor/main.py
+++ b/tools/edit_monitor/main.py
@@ -72,7 +72,8 @@ def configure_logging(verbose=False):
root_logging_dir = tempfile.mkdtemp(prefix='edit_monitor_')
_, log_path = tempfile.mkstemp(dir=root_logging_dir, suffix='.log')
- log_fmt = '%(asctime)s %(filename)s:%(lineno)s:%(levelname)s: %(message)s'
+
+ log_fmt = '%(asctime)s.%(msecs)03d %(filename)s:%(lineno)s:%(levelname)s: %(message)s'
date_fmt = '%Y-%m-%d %H:%M:%S'
log_level = logging.DEBUG if verbose else logging.INFO