Отдельно разберём TaskGroup, который пришел на замену gather в Python 3.11.
Ключевые отличия
▫️create_task() возвращает объект asyncio.Task, у которого есть соответствюущие методы управления. То есть у нас больше контроля
▫️это контекстный менеджер, который гарантирует что все таски будут остановлены по выходу из контекста
▫️ошибка автоматически отменяет незавершенные задачи,
▫️except* передает нам ExceptionGroup, в котором каждую ошибку можно обработать отдельно
import asyncio
import random
async def do_it() -> str:
if random.random() < 0.1:
raise ValueError('Oops')
delay = random.uniform(0.5, 1.5)
await asyncio.sleep(delay)
return delay
async def main():
try:
async with asyncio.TaskGroup() as tg:
for _ in range(10):
tasks.append(tg.create_task(do_it()))
for t in tasks:
print(t.result())
except *ValueError as e:
for err in e.exceptions:
print(err)
asyncio.run(main())
Рекомендую изучить страницу Coroutines and Tasks из документации, где представлено больше интересных примеров и механизмов
- таймауты
- отмена задач
- создание задач из другого потока
#async
Gatto Channel: June Events Calendar
#calendar#events
Gatto | Official Channel (18+) has released a calendar of regular events for June. Collaborations, raffles, and secret events are not listed, requiring subscribers to stay tuned for further announcements.
Source: link
@tonlines
In 46 BC, Julius Caesar added 90 extra days to the year, making it 445 days long. This was done to fix the calendar’s drift from the solar year. The previous calendar was out of sync with the seasons. Caesar introduced the Julian calendar, which included leap years every four years to keep the calendar aligned with the sun.
📅🔧
[Read more]
@googlefactss
#History#Calendar#LeapYear
🌍 Samoa famously skipped December 30, 2011, to switch from the eastern to the western side of the International Date Line. This move aligned its calendar with Australia and New Zealand. ✨
#Samoa⚡#dateline⚡#calendar⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
📅 Calendar Stickers 📅
https://telegram.me/addstickers/Calendar2016
#Calendar#Useful#Hacks
🛠 It could be useful (or even some sort of a lifehack) for users.
Fokus
To Do app tailored specifically for #students
Fokus is an open source application that combines a #todo list and a #calendar that can help you manage your #school related #work and #events in one place. It's fast and beautiful yet simple design that can help you focus on what matters most.
Features:
• Get reminded when a task is nearing its due
• Get reminded about incoming events
• Add attachments to your tasks
• Persistent notifications for important tasks or events
• No ads or any tracking
• Open Source Code
• On-Device Database
Download: https://github.com/icabetong/fokus-android/releases/
https://github.com/icabetong/fokus-android
@foss_Android