From 40f1d6963ba7c11c595e992100587d25185f483b 2011-07-04 17:44:42 From: MinRK Date: 2011-07-04 17:44:42 Subject: [PATCH] prevent race condition in purge_results test There were some cases where the Hub could be too slow noticing that the result was finished, causing an error saying that pending messages cannot be purged. --- diff --git a/IPython/parallel/tests/test_client.py b/IPython/parallel/tests/test_client.py index 42c3b60..094854c 100644 --- a/IPython/parallel/tests/test_client.py +++ b/IPython/parallel/tests/test_client.py @@ -249,7 +249,14 @@ class TestClient(ClusterTestCase): # ensure there are some tasks for i in range(5): self.client[:].apply_sync(lambda : 1) + # Wait for the Hub to realise the result is done: + # This prevents a race condition, where we + # might purge a result the Hub still thinks is pending. + time.sleep(0.1) + rc2 = clientmod.Client(profile='iptest') hist = self.client.hub_history() + ahr = rc2.get_result([hist[-1]]) + ahr.wait(10) self.client.purge_results(hist[-1]) newhist = self.client.hub_history() self.assertEquals(len(newhist)+1,len(hist))