Skip to navigation
Test asyncio
01.02.19
tasks = [] task = asyncio.create_task(self._get('1')) tasks.append(task) task2 = asyncio.create_task(self._get('2')) tasks.append(task) task3 = asyncio.create_task(self._get('3')) tasks.append(task) task4 = asyncio.create_task(self._get('4')) tasks.append(task) res = asyncio.gather(*tasks) r = await res #process the results after getting it all for i in r: print(i) async def _get(self,task): r = random.randint(0,10) x = await asyncio.sleep(r) print('task: {} waited: {}'.format(task,r))
Reply
Anonymous
Information Epoch 1732645900
Live free or die.
Home
Notebook
Contact us