Commit 96d94c21 authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

fix race conditions

parent ade01774
...@@ -1628,6 +1628,7 @@ class ManagerTestCase(unittest.TestCase): ...@@ -1628,6 +1628,7 @@ class ManagerTestCase(unittest.TestCase):
conditions[id].wait() conditions[id].wait()
actual_lst.append(("stop", id)) actual_lst.append(("stop", id))
@asyncio.coroutine
def _process(id, reset, rescheduled): def _process(id, reset, rescheduled):
with lock: with lock:
self.assertNotIn(id, conditions) self.assertNotIn(id, conditions)
...@@ -1917,9 +1918,9 @@ class ManagerTestCase(unittest.TestCase): ...@@ -1917,9 +1918,9 @@ class ManagerTestCase(unittest.TestCase):
rescheduled[id] = rsc_fut rescheduled[id] = rsc_fut
return fut.result() return fut.result()
manager = controller.Manager(2) manager = controller.Manager(2)
manager._process = lambda *k: manager.run_in_executor(worker, *k) manager._process = asyncio.coroutine(
lambda *k: manager.run_in_executor(worker, *k))
@asyncio.coroutine @asyncio.coroutine
...@@ -1957,6 +1958,8 @@ class ManagerTestCase(unittest.TestCase): ...@@ -1957,6 +1958,8 @@ class ManagerTestCase(unittest.TestCase):
yield from asyncio.wait_for(fut, timeout=.1) yield from asyncio.wait_for(fut, timeout=.1)
self.assertEquals(fut.result(), 43) self.assertEquals(fut.result(), 43)
self.assertFalse(fut2.done()) self.assertFalse(fut2.done())
yield from asyncio.sleep(.1)
# since the task is restarted, the 'rescheduled' is recreated # since the task is restarted, the 'rescheduled' is recreated
self.assertFalse(rescheduled[2].done()) self.assertFalse(rescheduled[2].done())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment