funboost-async-programming

Implements async/await consumption, publishing, and RPC result handling in funboost task queues.

892|166|Updated Dec 25, 2021
One-click install
npx skills add https://github.com/ydf0509/funboost --skill funboost-async-programming-ydf0509
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: funboost-async-programming
Source: https://github.com/ydf0509/funboost/tree/main/.agents/skills/funboost-async-programming
Command: npx skills add https://github.com/ydf0509/funboost --skill funboost-async-programming-ydf0509

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires funboost.

What problem does it solve? Writing asyncio-based consumers and publishers in funboost raises event loop conflicts, blocked loops from synchronous RPC calls, and confusion about which concurrency mode to choose. This Skill provides the correct patterns for async def consumers, aio_push/aio_publish publishing, and non-blocking RPC result retrieval. ## Core Features & Use Cases - Async Consumer Configuration: Set up async def consumption functions with ConcurrentModeEnum.ASYNC, or run coroutines under the default THREADING mode without loop management. - Async Publishing and RPC: Use aio_push/aio_publish for non-blocking task submission and AioAsyncResult to await results without freezing the event loop. - Event Loop Troubleshooting: Resolve errors like "attached to a different loop" and "This event loop is already running" using specify_async_loop and correct startup ordering. - Use Case: In a FastAPI service, publish an order-processing task with await handle_order.aio_push(order_id) and return the result via await AioAsyncResult(task_id).result without blocking other requests. ## Quick Start Ask the AI to write a funboost async consumer using ConcurrentModeEnum.ASYNC with aio_push publishing and AioAsyncResult for retrieving the RPC result in a FastAPI endpoint.

Frequently Asked Questions about funboost-async-programming

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write an async consumer function in funboost?▼

Define the function with async def and set concurrent_mode=ConcurrentModeEnum.ASYNC in BoosterParams, then start it with func.consume(). The default THREADING mode can also run async def functions by creating a temporary loop per thread.

How do I publish funboost tasks from FastAPI or asyncio code?▼

Use await func.aio_push(*args) for business parameters or await func.aio_publish(dict, task_options=...) for control options. Both wrap the synchronous publish in run_in_executor and return an AioAsyncResult.

Should I use ASYNC or THREADING concurrent mode for async def functions?▼

Choose ConcurrentModeEnum.ASYNC when your stack is fully asyncio-based (aiohttp, aiomysql) and you want lightweight coroutine concurrency. Keep the default THREADING mode for mixed sync/async code to avoid cross-thread loop issues.

Why does funboost raise 'attached to a different loop' with aiohttp?▼

ASYNC mode runs its loop in a child thread, but libraries like aiohttp and aiomysql bind connection pools to the loop where they were created. Pass specify_async_loop=loop in BoosterParams or create sessions inside the function to fix it.

Why does my FastAPI app freeze when fetching funboost RPC results?▼

Calling async_result.result blocks the entire event loop. Replace it with await AioAsyncResult(task_id).result, and ensure is_using_rpc_mode=True with Redis configured for RPC mode.

Can I get RPC results without Redis in funboost async mode?▼

Yes, with MEMORY_QUEUE you can use publisher.get_aio_future(*args) and await the returned future to get the result status. Redis-based RPC via is_using_rpc_mode is only required for persistent cross-process results.