async def _http_client_pool(self, client):

        tasks = MultiTasks()

        for url in TEST_URLS:
            tasks.append(client.get(url))

        await tasks

        assert all(tasks)
Beispiel #2
0
    async def run(self, times, task_num):

        self._publisher.open()

        for _ in range(times):

            tasks = MultiTasks()

            for _ in range(task_num):
                tasks.append(self._task_cls(self._publisher).run())

            await tasks

        await self._publisher.safe_close()
    async def test_multi_tasks_and_share_future(self):
        @ShareFuture()
        async def _do_acton():
            await Utils.sleep(1)
            return Utils.randint(0, 0xffff)

        assert (await _do_acton()) != (await _do_acton())

        tasks = MultiTasks()

        for _ in range(0xff):
            tasks.append(_do_acton())

        await tasks

        assert len(set(tasks)) == 1
Beispiel #4
0
    async def get(self):

        data_source = DataSource()

        tasks = MultiTasks()

        tasks.append(data_source.cache_health())
        tasks.append(data_source.mysql_health())
        tasks.append(data_source.mongo_health())

        await tasks

        return self.render(r'home/default.html',
                           cache_health=tasks[0],
                           mysql_health=tasks[1],
                           mongo_health=tasks[2])
Beispiel #5
0
    async def health(self):

        result = False

        with catch_error():

            tasks = MultiTasks()

            tasks.append(self.cache_health())
            tasks.append(self.mysql_health())
            tasks.append(self.mongo_health())

            await tasks

            result = all(tasks)

        return result