Три способа выполнить множество задач с 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
The RKM 740 Tower.
Architecture studio J Mayer H has completed a mixed-use tower in Düsseldorf, Germany, with profiled metal cladding that opens up like a zipper to provide views through its glazed facades.
J Mayer H won an international competition in 2011 to design the tower, which contains several medical facilities and apartments on the former grounds of the Dominikus-Krankenhaus hospital.
#architecture#arch_shovel#archdaily#NewsArchitecture
Silicon Valley.
Nearly 10 years in the making and the team of 1000+ designers, inventors, programmers, & builders can finally celebrate Google’s first ground-up campus! ⠀
Architecture: BIG
Location: Silicon Valley, California
#arch_shovel#architecture#NewsArchitecture#big
Bridge of spheres.
A futuristic bridge will appear in the Moscow City business center. The project was developed by the chief architect of Moscow Sergey Kuznetsov and architect Dmitry Sukhov.
#arch_shovel#architecture#NewsArchitecture#Кузнецов_проекты
Vltava Philharmonic Hall by Mecanoo.
The competition entry of Vltava Philharmonic Hall, a new musical and cultural center located in the heart of Prague.
Architecture: Mecanoo collaboration with Chybik+Kristof
Image: by Plo.mp, Mangoshake studio and Mecanoo
#NewsArchitecture#News#Architecture#arch_shovel#competition
The proposal for the Philharmonic Hall in Prague by Henning Larsen.
The new Prague Vltava Philharmonic will be the perfect ‘instrument’ - an expression of this place - realized in a new artistic language. Its cresting spires play in harmony with the towers, turrets, steeples and spires that grace the tapestry of the city’s roofscape.
Architecture: Henning Larsen
#danisharchitecture#arch_shovel#NewsArchitecture#competititon#architecture
Philharmonic Hall in Prague by Ludgaard & Tranberg.
Ludgaard & Tranberg’s design proposal created in collaboration with Cobe Architects for the Vlatava Philharmonic Hall in Prague. Music, art, architecture, the city and the audience converge in a concert hall that extends its vibrations far beyond the site by the river Vltava.
Architecture: Ludgaard & Tranberg & Cobe Architects
Acoustics: Gade & Mortensen Akustik
Consultation: Tyrens
#danisharchitecture#arch_shovel#NewsArchitecture#competititon#architecture
The project of a new residential complex in Moscow was approved.
The main design element is small balconies, which resemble a skin of the fantastic animal.
Architecture: “LABVA PRO” LTD bureau and “Architectural Bureau of Katerina Gren”.
#arch_shovel#architecture#moscow#residential#complex#new#NewsArchitecture
The Vltava Philharmonic Hall.
The new Vltava Philharmonic will be built by the Danish architectural studio Bjarke Ingels Group (BIG).
BIG plans to complete the new building in 2032.
“The Vltava Philharmonic Hall is composed as a meandering journey from riverbank to rooftop. Public flows and belvedere plazas unite the city life of Prague to the music within. Its halls are formed for sight, fine-tuned for sound, and orchestrated for functionality and connectivity. From this rhythmic structure, a symphony of colonnades and balconies extend as platforms for public life. Expressive yet pragmatic, the new Philharmonic will ascend to form a key landmark for Prague - from river to roof.” Bjarke Ingels, Founder & Partner, BIG.
#arch_shovel#conpetition#award#cultural#BIG#news#NewsArchitecture
The Shanghai Lingang Special Area master plan.
Design: Ennead Architects
Location: Shanghai, China
Ennead Architects has designed the Shanghai Lingang Special Area master plan (a new hub for global commerce) around the central axis that defines the Dishui Lake district in Shanghai.
One of the key features of the Shanghai Lingang Special Area will be “The Ring”. This circular, cantilevered observation deck, and museum will afford 360-degree views of nearby Dishui Lake, Shanghai and the Pacific Ocean.
The two towers flanking the Ring (The Tower Waterfall and Tower Rhomboid) are designed to become two of the most easily recognizable features of the new business district. Similar in scale, the towers have distinct identities.
#Architecture#arch_shovel#NewsArchitecture#News#Shanghai#China#Masterplan#CityPlanning#OfficeBuilding#CommercialArchitecture#UrbanDistrict#UrbanDesign