示例#1
0
 def test_db_query_get_result(self):
     """pop in db_query shouldn't pop from result itself"""
     self.client[:].apply_sync(lambda: 1)
     found = self.client.db_query({'msg_id': {'$ne': ''}})
     rc2 = clientmod.Client(profile='iptest')
     # If this bug is not fixed, this call will hang:
     ar = rc2.get_result(self.client.history[-1])
     ar.wait(2)
     self.assertTrue(ar.ready())
     ar.get()
     rc2.close()
 def test_get_result(self):
     """test getting results from the Hub."""
     c = clientmod.Client(profile='iptest')
     t = c.ids[-1]
     ar = c[t].apply_async(wait, 1)
     # give the monitor time to notice the message
     time.sleep(.25)
     ahr = self.client.get_result(ar.msg_ids[0], owner=False)
     self.assertIsInstance(ahr, AsyncHubResult)
     self.assertEqual(ahr.get(), ar.get())
     ar2 = self.client.get_result(ar.msg_ids[0])
     self.assertNotIsInstance(ar2, AsyncHubResult)
     self.assertEqual(ahr.get(), ar2.get())
     c.close()
示例#3
0
 def test_get_execute_result(self):
     """test getting execute results from the Hub."""
     c = clientmod.Client(profile='iptest')
     t = c.ids[-1]
     cell = '\n'.join(['import time', 'time.sleep(0.25)', '5'])
     ar = c[t].execute("import time; time.sleep(1)", silent=False)
     # give the monitor time to notice the message
     time.sleep(0.25)
     ahr = self.client.get_result(ar.msg_ids[0], owner=False)
     self.assertIsInstance(ahr, AsyncHubResult)
     self.assertEqual(ahr.get().execute_result, ar.get().execute_result)
     ar2 = self.client.get_result(ar.msg_ids[0])
     self.assertNotIsInstance(ar2, AsyncHubResult)
     self.assertEqual(ahr.get(), ar2.get())
     c.close()
示例#4
0
 def test_purge_hub_results(self):
     # 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.
     self._wait_for_idle()
     rc2 = clientmod.Client(profile='iptest')
     hist = self.client.hub_history()
     ahr = rc2.get_result([hist[-1]])
     ahr.wait(10)
     self.client.purge_hub_results(hist[-1])
     newhist = self.client.hub_history()
     self.assertEqual(len(newhist) + 1, len(hist))
     rc2.close()