lower the probability of marking living monkeys as dead

living monkeys will now be auto-marked as dead only if not a single
living monkey sent keep-alive in the last 10 minutes
This commit is contained in:
itsikkes 2016-08-13 19:39:09 +03:00
parent 2443e3fe4b
commit 72fc0c3bba
1 changed files with 5 additions and 0 deletions

View File

@ -296,6 +296,11 @@ def output_json(obj, code, headers=None):
def update_dead_monkeys():
# Update dead monkeys only if no living monkey transmitted keepalive in the last 10 minutes
if mongo.db.monkey.find_one({'dead': {'$ne': True}, 'keepalive': {'$gte': datetime.now() - timedelta(minutes=10)}}):
return
mongo.db.monkey.update(
{'keepalive': {'$lte': datetime.now() - timedelta(minutes=10)}, 'dead': {'$ne': True}},
{'$set': {'dead': True, 'modifytime': datetime.now()}}, upsert=False, multi=True)