From bce910100fe0c3970b82d4f5544f11ce3392bc3c Mon Sep 17 00:00:00 2001 From: Collin Fair Date: Fri, 24 Oct 2014 21:28:07 -0700 Subject: [PATCH] Remove NoQueueMinCycleTime nonsense from sync worker --- sync_worker.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/sync_worker.py b/sync_worker.py index 6a9a056e7..9c7b6387a 100644 --- a/sync_worker.py +++ b/sync_worker.py @@ -13,7 +13,6 @@ Run = True RecycleInterval = 2 # Time spent rebooting workers < time spent wrangling Python memory management. -NoQueueMinCycleTime = timedelta(seconds=30) # No need to hammer the database given the number of sync workers I have oldCwd = os.getcwd() WorkerVersion = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, cwd=os.path.dirname(__file__)).communicate()[0].strip() @@ -47,18 +46,12 @@ def sync_heartbeat(state, user=None): Sync.InitializeWorkerBindings() +sync_heartbeat("ready") + while Run: cycleStart = datetime.utcnow() # Avoid having synchronization fall down during DST setback processed_user_count = Sync.PerformGlobalSync(heartbeat_callback=sync_heartbeat, version=WorkerVersion) RecycleInterval -= processed_user_count - # When there's no queue, all the workers sit sending 1000s of the queries to the database server - if processed_user_count == 0: - # Put this before the recycle shutdown, otherwise it'll quit and get rebooted ASAP - remaining_cycle_time = NoQueueMinCycleTime - (datetime.utcnow() - cycleStart) - if remaining_cycle_time > timedelta(0): - print("Pausing for %ss" % remaining_cycle_time.total_seconds()) - sync_heartbeat("idle-spin") - time.sleep(remaining_cycle_time.total_seconds()) if RecycleInterval <= 0: break sync_heartbeat("idle")