From 6eea834777f0efd3c5727053ae4f7f4c303332f2 Mon Sep 17 00:00:00 2001 From: Massimo Date: Fri, 5 Apr 2013 16:01:13 -0500 Subject: [PATCH] fixed bug in scheduler context switch, thanks Niphlod --- VERSION | 2 +- gluon/scheduler.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index d9beb281..10e32df1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.5-stable+timestamp.2013.04.04.21.10.38 +Version 2.4.5-stable+timestamp.2013.04.05.15.59.29 diff --git a/gluon/scheduler.py b/gluon/scheduler.py index 6c5eafd2..2dea4efe 100644 --- a/gluon/scheduler.py +++ b/gluon/scheduler.py @@ -812,14 +812,16 @@ class Scheduler(MetaScheduler): ticker = all_active.find(lambda row: row.is_ticker is True).first() not_busy = self.worker_status[0] == ACTIVE if not ticker: + #if no other tickers are around if not_busy: - #only if this worker isn't busy, otherwise wait for a free one + #only if I'm not busy db(sw.worker_name == self.worker_name).update(is_ticker=True) db(sw.worker_name != self.worker_name).update(is_ticker=False) logger.info("TICKER: I'm a ticker") else: - #giving up, only if I'm not alone - if len(all_active) > 1: + #I'm busy + if len(all_active) >= 1: + #so I'll "downgrade" myself to a "poor worker" db(sw.worker_name == self.worker_name).update(is_ticker=False) else: not_busy = True