fastapi/asyncer/asyncer
Claude Code and agent skill by fastapi/asyncer
- community
Checking that the SKILL.md file is still in the repository.
Use Asyncer correctly in Python code that mixes async functions, blocking sync functions, worker threads, or concurrent async tasks. Use when choosing between Asyncer, AnyIO, and asyncio patterns; replacing asyncio.gather, AnyIO task groups, to_thread/from_thread calls, or anyio.run wrappers; using asyncer.create_task_group(), TaskGroup.soonify(), SoonValue, asyncify(), syncify(), or runnify(); or avoiding common Asyncer mistakes.
Install
npx vskill@latest install fastapi/asyncer/asyncerSKILL.md
Asyncer Patterns
Use this skill when writing Python code that mixes async functions, blocking sync functions, or concurrent async work and the project depends on asyncer.
Asyncer is a small typed layer on top of AnyIO. Prefer the Asyncer helpers below when they fit, because they preserve function signatures, keyword arguments, and return types better than the lower-level AnyIO or asyncio calls.
Imports
Use one of these styles:
For task groups, prefer asyncer.create_task_group() so the returned task group has Asyncer's extra soonify() method.
Concurrent Async Work
Prefer asyncer.create_task_group() plus task_group.soonify() for concurrent async function calls.
Use this instead of:
or raw task creation when the goal is simply "start these async calls concurrently and collect their results".
Do not use task_group.soon(...); Asyncer's API is task_group.soonify(...). The call shape is:
soonify() returns a SoonValue[T]. Read soon_value.value after the async with block, because exiting the task group waits for the scheduled tasks to finish.
Inside the same task group, .value can raise PendingValueException if the task is not complete. If there was an await inside the block and you truly need to inspect a value before exiting, check .ready first:
If code needs to consume values while producer tasks are still running, use a stream/channel pattern instead of SoonValue.value inside the task group.
If a task started with soonify() raises, the exception propagates when exiting the task group. Do not write code that assumes all SoonValue.value results are available after a failed task group unless the failure is caught and handled intentionally.
Call Sync Code From Async Code
Use asyncer.asyncify() when async code must call a blocking sync function without blocking the event loop.
Use this instead of directly calling blocking functions from async code, and instead of lower-level patterns such as loop.run_in_executor(...) or anyio.to_thread.run_sync(...) when you want better argument and return typing.
asyncify() accepts AnyIO thread options:
Use abandon_on_cancel, not the deprecated cancellable argument. Pass a limiter= when the caller needs to limit concurrent worker threads.
Call Async Code From Sync Code
Use asyncer.syncify() from sync code that is running in a worker thread started by async code. A common chain is:
- An async app or function is running.
- It calls sync/blocking code with
asyncify()or a framework-managed worker thread, such as a FastAPI sync endpoint or sync dependency. - That sync code needs to call an async function.
Use this instead of anyio.from_thread.run(...) when passing keyword arguments or when type support matters.
Do not use syncify() inside an async function. In async code, use plain await on the async function directly.
For sync functions that must work both from an async worker thread and from a plain sync program, syncify(..., raise_sync_error=False) is available:
Use this compatibility mode sparingly. Outside a worker thread it starts a new event loop with anyio.run(), which is expensive if repeated in a loop. If you need many calls, wrap the loop in one async function and run that once.
Run An Async Function From Sync Top-Level Code
Use asyncer.runnify() when sync top-level code needs to run one async function with positional or keyword arguments and the current thread is not already running an event loop.
Use this instead of manually wrapping arguments for anyio.run(...):
Do not call runnify() from a thread that already has a running event loop; from async code, just await main(...).
Choosing The Asyncer Alternative
Use these replacements by default when Asyncer is available:
asyncio.gather(...)for a batch of async calls with typed results:asyncer.create_task_group()plustask_group.soonify(...).anyio.create_task_group().start_soon(...)for ordinary async function calls:asyncer.create_task_group().soonify(...), especially when kwargs or return values matter.anyio.to_thread.run_sync(...),asyncio.to_thread(...), orloop.run_in_executor(...):await asyncer.asyncify(sync_func)(...).anyio.from_thread.run(...):asyncer.syncify(async_func)(...).anyio.run(async_func, ...)from sync top-level code with arguments:asyncer.runnify(async_func)(...).
Still use lower-level AnyIO primitives when Asyncer does not provide the abstraction, such as streams, locks, events, capacity limiters themselves, cancellation scopes, timeouts, or task-group startup handshakes that need task_status.started().
Common Mistakes
- Do not call blocking sync functions directly from
async def; wrap them withawait asyncify(sync_func)(...). - Do not use
syncify()as a general replacement forawait; it is for sync code, normally in a worker thread started by async code. - Do not wrap async functions when already in async code; use plain
await async_func(...). - Do not read
SoonValue.valuebefore the task has completed unlesssoon_value.readyis true. - Do not instantiate
asyncer.TaskGroupdirectly; useasyncer.create_task_group().
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingasyncer/.agents/skills/asyncer/SKILL.md
Popularity
- Repository stars
- 2,467
- Repository forks
- 87
- 7-day trend score
- 39
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/fastapi/asyncer/asyncer)