This skill helps you write robust async code with safe_gather, proper timeouts, and clean cancellation for concurrent tasks.
npx playbooks add skill gigaverse-app/skillet --skill pythonista-async
safe_gather for all new async code - fail-fast, timeout support, cleaner cancellationreturn_exceptions=True for partial-results patternssafe_gather is better in ALL cases because it provides:
return_exceptions=True)See [references/safe-gather.md](references/safe-gather.md) for implementation.
# Initialization - all workers must start
await safe_gather(*[worker.pre_run() for worker in workers])
# Data fetching - need all pieces
channel_info, front_row, participants = await safe_gather(
fetch_channel_info(channel_id),
fetch_front_row(channel_id),
fetch_participants(channel_id),
)
# With timeout
results = await safe_gather(*tasks, timeout=30.0)
# Use safe_gather with return_exceptions=True
results = await safe_gather(*batch_tasks, return_exceptions=True)
for result in results:
if isinstance(result, Exception):
logger.error(f"Task failed: {result}")
else:
process(result)
# With timeout
results = await safe_gather(*batch_tasks, return_exceptions=True, timeout=30.0)
# With timeout for cleanup (don't wait forever)
await safe_gather(
service1.shutdown(),
service2.shutdown(),
return_exceptions=True,
timeout=10.0
)
# OK to keep existing asyncio.gather for cleanup
await asyncio.gather(*cancelled_tasks, return_exceptions=True)
Is this new code?
├─ Yes -> Use safe_gather
└─ No (existing code)
└─ Is it cleanup with return_exceptions=True?
├─ Yes -> Keep asyncio.gather (optional to migrate)
└─ No -> Would fail-fast or timeout help?
├─ Yes -> Migrate to safe_gather
└─ No -> Low priority
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.