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

Резултати

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

Пребарај: #mentalgrowth

当前筛选 #mentalgrowth清除筛选

Hard work is a must thing for success. Smart work is not a substitute for hard work, it is another wing of the bird which can take you to your success. In short, there is no substitute for hard work! You have to be ready for it. Put everything you have for what you want, This is the way of massive success! Problems are going to be there always! Tackle them. You have only two choices, one is EXCUSES and other is RESULTS. The choice is yours! Don’t sacrifice your dreams for temporary pleasure. Neither this pleasure is going to come with you nor this pain. Choose temporary pain for your permanent happiness. ⭐️ Give your 100% (not even 99%) for your dreams! Don’t run away from hard work. Thisis going to give you your dreams! ✨💪 #mentalGrowth#ipersonalgrowths#smarwork#hardwork

Fear or opportunity? Fears are the body's adequate reaction to something new, to something that once caused unpleasant consequences, or to something that directly or indirectly threatens one's life. But there are fears that simply must be overcome. For example, if you have an idea, but to implement it, you do not have the courage, and therefore and perseverance. It is behind such fears that lies your invaluable potential. The body never generates ideas that it doesn't have the resources to implement. Our thoughts are not random. Think of the opportunities that will open up before you after you overcome your fear. Have you imagined it? Now act! Join us for more -> @ipersonalgrowths💡 #MentalGrowth #Fear #opportunity #psychologyinformation