forked from p15670423/monkey
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:
parent
2443e3fe4b
commit
72fc0c3bba
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue