Remove the over-incrementing task ID

This commit is contained in:
Vincent Le Goff 2017-05-08 19:18:54 -07:00
parent 6ea13dbc96
commit 02a35972af
2 changed files with 6 additions and 4 deletions

View file

@ -45,7 +45,6 @@ class EventHandler(DefaultScript):
self.db.locked = []
# Tasks
self.db.task_id = 0
self.db.tasks = {}
def at_start(self):
@ -559,8 +558,12 @@ class EventHandler(DefaultScript):
"""
now = datetime.now()
delta = timedelta(seconds=seconds)
task_id = self.db.task_id
self.db.task_id += 1
# Choose a free task_id
used_ids = list(self.db.tasks.keys())
task_id = 1
while task_id in used_ids:
task_id += 1
# Collect and freeze current locals
locals = {}

View file

@ -58,7 +58,6 @@ class TestEventHandler(EvenniaTest):
self.assertEqual(self.handler.db.to_valid, [])
self.assertEqual(self.handler.db.locked, [])
self.assertEqual(self.handler.db.tasks, {})
self.assertEqual(self.handler.db.task_id, 0)
self.assertIsNotNone(self.handler.ndb.events)
def test_add_validation(self):