Функция asyncio.wait() это еще один способ вызвать множество асинхронных задач.
Она работает в нескольких режимах.
1. Самый простой - ждем завершения всех задач
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(10)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.ALL_COMPLETED
)
for task in done:
try:
print(task.result())
except Exception as e:
print(e)
Очень похоже на gather, но работает не так.
▫️возвращает не результаты, а два сета с объектами Task у которых можно забрать результат через task.result() если они в списке done
▫️не гарантирует порядок результатов так как оба объекта это set
▫️не выбрасывает исключение когда оно появляется, а сохраняет его в Task. Исключение появится когда попробуете забрать резултьтат.
2. Ждем завершения первой задачи, даже если там ошибка.
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(3)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_COMPLETED
)
# в done может быть несколько задач!
for task in done:
try:
print(task.result())
except Exception as e:
print(f"Fail: {e}")
# Оставшиеся задачи в pending, как правило, нужно отменить, иначе они будут продолжать работать
for task in pending:
task.cancel()
В сете done будут таски которые успели завершится, причем как успешно так и нет.
3. До первой ошибки.
Тоже самое, но с аргументом FIRST_EXCEPTION
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_EXCEPTION
)
Функция завершается как только первая задача упадет с ошибкой.
Учтите, что в любом случае done вы можете обранужить несколько задач, как с ошибками так и успешные.
↗️ Полный листинг примеров здесь
#async
DC The Batman Season 5
📅Año Septiembre 2007 - Marzo 2008
🎥Dirección Brandon Vietti, Seung Eun Kim, Anthony Chun, Sam Liu, Vinton Heuck, Chris Berkeley, Matt Youngberg, John Fang
👤Personajes#BobKane
🎼Música Thomas Chase
🎬Productora Warner Bros. Animation, DC Comics, Warner Bros.
Productor#MichaelGoguen (Creador), #DuaneCapizzi (Creador)
Género#SeriedeTV#Animación#Fantástico#Acción#Superhéroes#Cómic#DCComics
Resumen
Batman, Batgirl y Robin hacen equipo con la Liga de la Justicia, y también con aquellos que no forman parte de la Liga como Superman, que por cierto usaron a Brandon Routh como base para este Superman y curiosamente el propio Routh hace la voz del villano Vértigo. Este sería el fin de la serie a pesar de dejar un final abierto.
⏱Duración 22min.
🖥Resolución 720x400
🗣Idioma Latino
Season 5 Episodio 01 - 02 - 03 - 04 - 05 - 06 - 07 - 08 - 09 -10 - 11 - 12 - 13
Season1 - 2 - 3 - 4
Suscripción a esta Serie 👉🏻Aquí
Índice de Animaciones 👉🏻Aquí
DC The Batman Season 4
📅Año Septiembre 2006 - Mayo 2007
🎥Dirección Brandon Vietti, Seung Eun Kim, Anthony Chun, Sam Liu, Vinton Heuck, Chris Berkeley, Matt Youngberg, John Fang
👤Personajes#BobKane
🎼Música Thomas Chase
🎬Productora Warner Bros. Animation, DC Comics, Warner Bros.
Productor#MichaelGoguen (Creador), #DuaneCapizzi (Creador)
Género#SeriedeTV#Animación#Fantástico#Acción#Superhéroes#Cómic#DCComics
⏱Duración 22min.
🖥Resolución 720x400
🗣Idioma Latino
Resumen
Dick Grayson era un joven artista de circo, cuyos padres mueren en un accidente mientras realizaban una actuación en él. Tras ello, Bruce lo adopta. Robin comienza su vida de héroe. Batman, Robin y Batgirl unen fuerzas con el Detective Marciano para detener la invasión de la fuerza extraterrestre, conocida como "The Joining".
Season 4 Episodio01 - 02 - 03 - 04 - 05 - 06 - 07 - 08 - 09 - 10 - 11 - 12 - 13
Season1 - 2 - 3 - 5
Suscripción a esta Serie 👉🏻Aquí
Índice de Animaciones 👉🏻Aquí
DC The BatmanSeason 3
📅Año Septiembre 2005 - Mayo 2006
🎥Dirección Brandon Vietti, Seung Eun Kim, Anthony Chun, Sam Liu, Vinton Heuck, Chris Berkeley, Matt Youngberg, John Fang
👤Personajes#BobKane
🎼Música Thomas Chase
🎬Productora Warner Bros. Animation, DC Comics, Warner Bros.
Productor#MichaelGoguen (Creador), #DuaneCapizzi (Creador)
Género#SeriedeTV#Animación#Fantástico#Acción#Superhéroes#Cómic#DCComics
Resumen
Barbara Gordon, la hija del comisionado, asume el rol de Batgirl, aunque Batman no tiene ningún interés en que lo ayude en la lucha contra el crimen y trata de hacerla abandonar esa identidad. Esto acaba con el episodio Truenp, en el que Bruce, iluminado por su leal mayordomo y amigo, Alfred le toma a Batgirl como su ayudante.
⏱Duración 22min.
🖥Resolución 720x400
🗣Idioma Latino
Season 3 Episodio 01 - 02 - 03 - 04 - 05 - 06 - 07 - 08 - 09 - 10 - 11 - 12 - 13
Season1 - 2 - 4 - 5
Suscripción a esta Serie 👉🏻Aquí
Índice de Animaciones 👉🏻Aquí
The Batman Season 2
📅Año Mayo 2005 - Septiembre 2005
🎥Dirección Brandon Vietti, Seung Eun Kim, Anthony Chun, Sam Liu, Vinton Heuck, Chris Berkeley, Matt Youngberg, John Fang
👤Personajes#BobKane
🎼Música Thomas Chase
🎤Opening#TheEdge del grupo #U2
🎬Productora Warner Bros. Animation, DC Comics, Warner Bros.
Productor#MichaelGoguen (Creador), #DuaneCapizzi (Creador)
Género#SeriedeTV#Animación#Fantástico#Acción#Superhéroes#Cómic#DCComics
⏱Duración 22min.
🖥Resolución 608x448
🗣Idioma Latino
Season 2 Episodio01 - 02 - 03 - 04 - 05 - 06 - 07 - 08 - 09 - 10 - 11 - 12 - 13
Season1 - 3 - 4 - 5
Suscripción a esta Serie 👉🏻Aquí
Índice de Animaciones 👉🏻Aquí
The BatmanSeason 1
📅Año 2004
🎥Dirección Brandon Vietti, Seung Eun Kim, Anthony Chun, Sam Liu, Vinton Heuck, Chris Berkeley, Matt Youngberg, John Fang
📄Guion Steven Melching, Alexx Van Dyne, Joseph Kuhr, Greg Weisman, Stan Berkowitz, Michael Jelenic, Bob Goodman, Jane Espenson, Douglas Petrie.
👤Personajes#BobKane
📝Diseño de Personajes#JeffMatsuda
🎼Música Thomas Chase
🎤Opening#TheEdge del grupo #U2
🎬Productora Warner Bros. Animation, DC Comics, Warner Bros.
Productor#MichaelGoguen (Creador), #DuaneCapizzi (Creador)
🚚Distribuidora The WB, The CW, HBO
Género#SeriedeTV#Animación#Fantástico#Acción#Superhéroes#Cómic#DCComics
Reparto | Intro | Sinopsis | Premios
⏱Duración 22min.
🖥Resolución 720x400
🗣Idioma Latino
Season 1 Episodio01 - 02 - 03 - 04 - 05 - 06 - 07 - 08 - 09 - 10 - 11 - 12 - 13
Season2 - 3 - 4 - 5
Suscripción a esta Serie 👉🏻Aquí
Índice de Animaciones 👉🏻Aquí