kjuhwa/skills-hub/async-sync-inference-bridge-with-tokio-blocking

Claude Code and agent skill by kjuhwa/skills-hub

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Provide both async and sync APIs for inference by writing the core as async and using tokio::task::block_in_place for the sync wrappers.

Install

npx vskill@latest install kjuhwa/skills-hub/async-sync-inference-bridge-with-tokio-blocking

SKILL.md

The same SKILL.md was published earlier as kjuhwa/skills-hub/async-sync-inference-bridge-with-tokio-blocking.

Async Sync Inference Bridge With Tokio Blocking

Trigger: Building an inference library that must serve both async (HTTP servers, tokio apps) and sync (CLIs, scripts) clients without two parallel codepaths.

Steps

  • Implement core inference as async fn identify_file(), async fn identify_content().
  • Provide thin sync wrappers (identify_file_sync, identify_content_sync) that call exec(async_method()).
  • Define an exec() helper that uses tokio::task::block_in_place inside a tokio runtime, or spawns a blocking thread when there is no runtime.
  • Document the contract: which methods are safe in which context.
  • Test both paths against the same input corpus; assert identical results.
  • Don't mix sync and async in the same call chain — design the API so callers commit to one world.

Counter / Caveats

  • block_in_place panics outside a tokio multi-thread runtime; provide a thread-pool fallback.
  • Sync wrappers carry runtime startup overhead; long sync loops are slower than one async batch.
  • File handle lifetimes differ: async drops at .await, sync holds until drop — beware file lock interactions.
  • Mixed sync/async can deadlock; document and lint against it.

Source

Extracted from magika (https://github.com/google/magika.git @ main).

Files of interest:

  • rust/lib/src/session.rs:40-47
  • rust/lib/src/future.rs
  • rust/lib/src/input.rs:15-102

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/kjuhwa/skills-hub/async-sync-inference-bridge-with-tokio-blocking/badge)](https://verified-skill.com/skills/kjuhwa/skills-hub/async-sync-inference-bridge-with-tokio-blocking)

Something wrong with this skill or its page? Tell us.