TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #400 · 8 дек.

Три способа выполнить множество задач с asyncio Функция для примера: async def do_it(n): await asyncio.sleep(random.uniform(0.5, 1)) return n 1. Последовательный вызов async def main(): for i in range(100): result = await do_it(i) Такой вызов имеет смысл только тогда, когда результат одной задачи требуется для вызова следующей. Если они независимы, то это антипаттерн, так как аналогичен простому синхронному вызову по очереди. 2. Упорядоченный результат async def main(): tasks = [do_it(i) for i in range(100)] results = await asyncio.gather(*tasks) Выполняет корутины конкурентно и возвращает результат в виде списка. Полезен когда требуется получить результаты в том же порядке в котором задачи отправлены. 3. Результат по мере готовности tasks = [asyncio.create_task(do_it(i)) for i in range(100)] for cor in asyncio.as_completed(tasks): result = await cor Так же выполняет корутины конкурентно, но не гарантирует порядок. Результат возвращается по мере готовности, каждый отдельно. Полезен когда нужно обработать любой ответ как можно скорее. #async

Hashtags

Резултати

Пронајдени 1 слични објави

Пребарај: #recent

当前筛选 #recent清除筛选
Journey to Fluency

@fluencyinenglish · Post #6907 · 26.02.2019 г., 15:19

#speaking #recent#tests @ieltsstrategies Writing General Task 1 (Letter) You have recently moved to a new apartment. Write a letter to your friend and explain: – Why you moveED – Describe the new apartment. – Invite him/her to visit you. Writing Task 2 (Essay) Some people think that giving homework to students is not a good idea. Others believe that homework is good and helps students achieve better grades. Discuss both views and give your own opinion. THIS IS AN EXAMPLE OF AN OPINION ESSAY. Speaking test Interview – What is your full name? – Can I see your ID? – Where are you from? – Do you work or study? – Do you read newspapers? – Does your family read newspapers? – Do you read any news online? – What section of the newspaper do you read first? Why? Cue Card Talk about a toy you had in your childhood. Please say – What the toy WAS – Who gave it to you – How old were you then – AND EXPLAIN Why you remember this toy Follow up question: Do you still have this toy? @ieltsstrategies Discussion – Who else played with your toy? – Did you like it? Why? – What kind of toys do girls like? – What is the difference between toys for girls and boys? THIS QUESTION AIMS TO ENCOURAGE YOU TO COMPARE AND CONTRAST – Is there a toy that was common in your childhood? – Should children be allowed to choose their toys? – What should you think of while buying toys? – Do children learn something from toys? @ieltsstrategies