def test_execute_async(self):
        f = self.task.execute_async()
        res = f.result(3.0)
        self.assertNotNone(res)
        self.assertGreater(res, 0)

        # Verify exception path
        self.task.fail_async = True
        with self.assertRaises(Exception) as ctx:
            # Call this twice, since there's a race condition where setting
            # fail_async and getting the future from execute_async is called
            # when execute is between the self.fail_async check and the return
            self.task.execute_async().result(1.0)
            self.task.execute_async().result(1.0)

        self.assertEqual(ctx.exception.args[0], "fail_async")

        # Wait until task shuts down
        with Timer() as t:
            while t.elapsed < 5.0:
                if not self.task.running:
                    break
            self.assertFalse(self.task.running)

        # Verify early exception on async_execute against shutdown tasks
        f = self.task.execute_async()
        with self.assertRaises(Exception) as ctx:
            f.result()
        self.assertEqual(ctx.exception.args[0], "Worker not running")
dataset/ETHPy150Open facebook/sparts/tests/tasks/test_periodic.py/TestMyTask.test_execute_async/original