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

Commit 7127855

Browse files
authored
Fix synctl and duplicate worker spawning (#8798)
Synctl did not check if a worker thread was already running when using `synctl start` and would naively start a fresh copy. This would sometimes lead to cases where many duplicate copies of a single worker would run. This fix adds a pid check when starting worker threads and synctl will now refuse to start individual workers if they're already running.
1 parent 59a995f commit 7127855

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

changelog.d/8798.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug where synctl could spawn duplicate copies of a worker. Contributed by Waylon Cude.

synctl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,13 @@ def main():
358358
for worker in workers:
359359
env = os.environ.copy()
360360

361+
# Skip starting a worker if its already running
362+
if os.path.exists(worker.pidfile) and pid_running(
363+
int(open(worker.pidfile).read())
364+
):
365+
print(worker.app + " already running")
366+
continue
367+
361368
if worker.cache_factor:
362369
os.environ["SYNAPSE_CACHE_FACTOR"] = str(worker.cache_factor)
363370

0 commit comments

Comments
 (0)