[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6H8Y0ATEYA1TGASFBW9XMG2":3,"skill-same:01M6H8Y0ATEYA1TGASFBW9XMG2":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":34,"frontMatter":35,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":14,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":43,"ownerDescription":44,"updatedAt":45,"install":46,"resources":59},"01M6H8Y0ATEYA1TGASFBW9XMG2","async-programming",null,"Asynchronous programming patterns and best practices","NeuralBlitz\u002FMito","NeuralBlitz","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F79354388?v=4","01M6H8T2TFH477HRS0KTSTKR2E","David Riggs","01M6H8T2YQQDXPYM092P670Z21",0,"MIT","https:\u002F\u002Fgithub.com\u002FNeuralBlitz\u002FMito\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Fasync-programming\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[24,25,26,27,28,29,30],"programming","async","async programming","best practices","asynchronous","opencode","patterns","2026-11-10 10:12:30",false,"---\nname: async-programming\ndescription: Asynchronous programming patterns and best practices\nlicense: MIT\ncompatibility: opencode\nmetadata:\n  audience: developers\n  category: programming\n---\n## What I do\n- Write async\u002Fawait code in Python and JavaScript\n- Implement concurrent operations\n- Handle async errors properly\n- Use thread pools and process pools\n- Implement producer-consumer patterns\n- Manage async resources with context managers\n- Handle backpressure and rate limiting\n- Debug async code\n\n## When to use me\nWhen implementing asynchronous operations or concurrency patterns.\n\n## Python Asyncio\n```python\nimport asyncio\nimport aiohttp\nfrom typing import List, Optional\nfrom dataclasses import dataclass\nfrom contextlib import asynccontextmanager\n\n\n@dataclass\nclass FetchResult:\n    url: str\n    status: int\n    content: str\n    duration_ms: float\n\n\nclass AsyncFetcher:\n    \"\"\"Concurrent HTTP fetcher with rate limiting.\"\"\"\n    \n    def __init__(\n        self,\n        max_concurrent: int = 10,\n        max_per_second: float = 5.0\n    ) -> None:\n        self.semaphore = asyncio.Semaphore(max_concurrent)\n        self.rate_limiter = AsyncRateLimiter(max_per_second)\n        self.results: List[FetchResult] = []\n    \n    async def fetch(\n        self,\n        session: aiohttp.ClientSession,\n        url: str,\n        timeout: int = 10\n    ) -> FetchResult:\n        \"\"\"Fetch a single URL with rate limiting.\"\"\"\n        async with self.semaphore:\n            async with self.rate_limiter:\n                start = asyncio.get_event_loop().time()\n                \n                try:\n                    async with session.get(\n                        url,\n                        timeout=aiohttp.ClientTimeout(total=timeout)\n                    ) as response:\n                        content = await response.text()\n                        duration = (asyncio.get_event_loop().time() - start) * 1000\n                        \n                        return FetchResult(\n                            url=url,\n                            status=response.status,\n                            content=content,\n                            duration_ms=duration,\n                        )\n                except Exception as e:\n                    return FetchResult(\n                        url=url,\n                        status=0,\n                        content=str(e),\n                        duration_ms=0,\n                    )\n    \n    async def fetch_all(\n        self,\n        urls: List[str],\n        progress_callback: Optional[callable] = None\n    ) -> List[FetchResult]:\n        \"\"\"Fetch multiple URLs concurrently.\"\"\"\n        async with aiohttp.ClientSession() as session:\n            tasks = [self.fetch(session, url) for url in urls]\n            \n            results = []\n            for i, coro in enumerate(asyncio.as_completed(tasks)):\n                result = await coro\n                results.append(result)\n                \n                if progress_callback:\n                    progress_callback(i + 1, len(urls))\n            \n            return results\n\n\nclass AsyncRateLimiter:\n    \"\"\"Token bucket rate limiter for async operations.\"\"\"\n    \n    def __init__(\n        self,\n        rate: float,  # tokens per second\n        capacity: Optional[int] = None\n    ) -> None:\n        self.rate = rate\n        self.capacity = capacity or int(rate)\n        self.tokens = self.capacity\n        self.last_update = asyncio.get_event_loop().time()\n        self.lock = asyncio.Lock()\n    \n    async def acquire(self, tokens: int = 1) -> float:\n        \"\"\"Acquire tokens, wait if necessary. Returns wait time.\"\"\"\n        async with self.lock:\n            now = asyncio.get_event_loop().time()\n            elapsed = now - self.last_update\n            \n            # Add tokens based on elapsed time\n            new_tokens = elapsed * self.rate\n            self.tokens = min(self.capacity, self.tokens + new_tokens)\n            self.last_update = now\n            \n            # Wait for tokens if needed\n            if self.tokens >= tokens:\n                self.tokens -= tokens\n                return 0.0\n            \n            # Calculate wait time\n            needed = tokens - self.tokens\n            wait_time = needed \u002F self.rate\n            self.tokens = 0\n            self.last_update = now + wait_time\n            \n            return wait_time\n    \n    async def __aenter__(self) -> 'AsyncRateLimiter':\n        await self.acquire()\n        return self\n    \n    async def __aexit__(self, *args) -> None:\n        pass\n\n\n@asynccontextmanager\nasync def async_timer(name: str):\n    \"\"\"Context manager for timing async operations.\"\"\"\n    start = asyncio.get_event_loop().time()\n    try:\n        yield\n    finally:\n        duration = (asyncio.get_event_loop().time() - start) * 1000\n        print(f\"{name}: {duration:.2f}ms\")\n```\n\n## Concurrent Processing\n```python\nimport asyncio\nfrom concurrent.futures import ThreadPoolExecutor\nfrom typing import List, TypeVar, Callable, Awaitable\n\n\nT = TypeVar('T')\nR = TypeVar('R')\n\n\nclass ConcurrentProcessor:\n    \"\"\"Process items with configurable concurrency.\"\"\"\n    \n    def __init__(\n        self,\n        max_workers: int = 10,\n        use_processes: bool = False\n    ) -> None:\n        self.max_workers = max_workers\n        self.executor = None\n        self.use_processes = use_processes\n    \n    def __enter__(self) -> 'ConcurrentProcessor':\n        if self.use_processes:\n            self.executor = ProcessPoolExecutor(max_workers=self.max_workers)\n        else:\n            self.executor = ThreadPoolExecutor(max_workers=self.max_workers)\n        return self\n    \n    def __exit__(self, *args) -> None:\n        self.executor.shutdown(wait=True)\n    \n    async def map(\n        self,\n        func: Callable[[T], R],\n        items: List[T],\n        progress_callback: Optional[Callable[[int], None]] = None\n    ) -> List[R]:\n        \"\"\"Map function over items concurrently.\"\"\"\n        loop = asyncio.get_event_loop()\n        tasks = []\n        \n        for item in items:\n            task = loop.run_in_executor(\n                self.executor,\n                func,\n                item\n            )\n            tasks.append(task)\n        \n        results = []\n        for i, future in enumerate(asyncio.as_completed(tasks)):\n            result = await future\n            results.append(result)\n            if progress_callback:\n                progress_callback(i + 1)\n        \n        return results\n    \n    async def map_ordered(\n        self,\n        func: Callable[[T], Awaitable[R]],\n        items: List[T]\n    ) -> List[R]:\n        \"\"\"Map async function preserving order.\"\"\"\n        tasks = [func(item) for item in items]\n        return await asyncio.gather(*tasks)\n\n\nclass ProducerConsumer:\n    \"\"\"Producer-consumer pattern with bounded queue.\"\"\"\n    \n    def __init__(\n        self,\n        max_queue_size: int = 100,\n        max_workers: int = 5\n    ) -> None:\n        self.queue = asyncio.Queue(max_queue_size)\n        self.workers = max_workers\n        self.running = True\n    \n    async def producer(self, items: List[T]) -> None:\n        \"\"\"Produce items for consumption.\"\"\"\n        for item in items:\n            await self.queue.put(item)\n        \n        # Signal completion\n        for _ in range(self.workers):\n            await self.queue.put(None)\n    \n    async def consumer(self, func: Callable[[T], Awaitable[R]]) -> List[R]:\n        \"\"\"Consume items and process them.\"\"\"\n        results = []\n        \n        while self.running:\n            item = await self.queue.get()\n            \n            if item is None:\n                self.queue.task_done()\n                break\n            \n            try:\n                result = await func(item)\n                results.append(result)\n            except Exception as e:\n                print(f\"Error processing item: {e}\")\n            finally:\n                self.queue.task_done()\n        \n        return results\n    \n    async def run(\n        self,\n        items: List[T],\n        func: Callable[[T], Awaitable[R]],\n        progress_callback: Optional[Callable[[int], None]] = None\n    ) -> List[R]:\n        \"\"\"Run the producer-consumer pipeline.\"\"\"\n        results = []\n        \n        async def worker():\n            while True:\n                item = await self.queue.get()\n                if item is None:\n                    break\n                try:\n                    result = await func(item)\n                    results.append(result)\n                finally:\n                    self.queue.task_done()\n        \n        # Start workers\n        workers = [worker() for _ in range(self.workers)]\n        \n        # Start producer\n        producer_task = asyncio.create_task(self.producer(items))\n        \n        # Wait for all\n        await asyncio.gather(producer_task, *workers)\n        \n        return results\n```\n\n## Error Handling\n```python\nimport asyncio\nfrom typing import Optional, TypeVar, Callable\nfrom dataclasses import dataclass\n\n\n@dataclass\nclass AsyncResult:\n    success: bool\n    value: Optional[R] = None\n    error: Optional[Exception] = None\n    duration_ms: float = 0\n\n\nclass AsyncErrorHandler:\n    \"\"\"Handle errors in async code with retries.\"\"\"\n    \n    def __init__(\n        self,\n        max_retries: int = 3,\n        backoff_factor: float = 1.0,\n        exceptions: tuple = (Exception,)\n    ) -> None:\n        self.max_retries = max_retries\n        self.backoff_factor = backoff_factor\n        self.exceptions = exceptions\n    \n    async def execute(\n        self,\n        func: Callable[..., Awaitable[R]],\n        *args,\n        **kwargs\n    ) -> AsyncResult[R]:\n        \"\"\"Execute with retry logic.\"\"\"\n        start = asyncio.get_event_loop().time()\n        \n        for attempt in range(self.max_retries + 1):\n            try:\n                result = await func(*args, **kwargs)\n                duration = (asyncio.get_event_loop().time() - start) * 1000\n                \n                return AsyncResult(\n                    success=True,\n                    value=result,\n                    duration_ms=duration,\n                )\n            \n            except self.exceptions as e:\n                if attempt == self.max_retries:\n                    duration = (asyncio.get_event_loop().time() - start) * 1000\n                    return AsyncResult(\n                        success=False,\n                        error=e,\n                        duration_ms=duration,\n                    )\n                \n                delay = self.backoff_factor * (2 ** attempt)\n                await asyncio.sleep(delay)\n        \n        duration = (asyncio.get_event_loop().time() - start) * 1000\n        return AsyncResult(success=False, duration_ms=duration)\n\n\nclass TimeoutHandler:\n    \"\"\"Handle async operations with timeouts.\"\"\"\n    \n    async def with_timeout(\n        self,\n        coro: Awaitable[R],\n        timeout: float,\n        fallback: Optional[Callable[[], R]] = None\n    ) -> R:\n        \"\"\"Execute with timeout.\"\"\"\n        try:\n            return await asyncio.wait_for(coro, timeout=timeout)\n        except asyncio.TimeoutError:\n            if fallback:\n                return fallback()\n            raise TimeoutError(f\"Operation timed out after {timeout}s\")\n    \n    async def with_individual_timeout(\n        self,\n        tasks: List[asyncio.Task],\n        timeout: float\n    ) -> List[Optional[R]]:\n        \"\"\"Wait for tasks with individual timeouts.\"\"\"\n        results = [None] * len(tasks)\n        \n        for i, task in enumerate(tasks):\n            try:\n                results[i] = await asyncio.wait_for(task, timeout=timeout)\n            except asyncio.TimeoutError:\n                results[i] = None\n            except Exception:\n                results[i] = None\n        \n        return results\n```\n\n## JavaScript Async\n```typescript\n\u002F\u002F Promise utilities\nclass AsyncUtils {\n  static async withTimeout\u003CT>(\n    promise: Promise\u003CT>,\n    timeoutMs: number,\n    fallback?: T\n  ): Promise\u003CT> {\n    return Promise.race([\n      promise,\n      new Promise\u003CT>((_, reject) =>\n        setTimeout(() => {\n          if (fallback !== undefined) {\n            resolve(fallback);\n          } else {\n            reject(new Error(`Timeout after ${timeoutMs}ms`));\n          }\n        }, timeoutMs)\n      ),\n    ]);\n  }\n\n  static async retry\u003CT>(\n    fn: () => Promise\u003CT>,\n    maxRetries: number = 3,\n    delayMs: number = 1000\n  ): Promise\u003CT> {\n    let lastError: Error | null = null;\n\n    for (let i = 0; i \u003C= maxRetries; i++) {\n      try {\n        return await fn();\n      } catch (e) {\n        lastError = e as Error;\n        if (i \u003C maxRetries) {\n          await new Promise(resolve => setTimeout(resolve, delayMs * (i + 1)));\n        }\n      }\n    }\n\n    throw lastError;\n  }\n\n  static async allSettled\u003CT>(\n    promises: Promise\u003CT>[]\n  ): Promise\u003C{ status: 'fulfilled' | 'rejected'; value?: T; reason?: Error }[]> {\n    return Promise.all(\n      promises.map(promise =>\n        promise\n          .then(value => ({ status: 'fulfilled' as const, value }))\n          .catch(reason => ({ status: 'rejected' as const, reason }))\n      )\n    );\n  }\n\n  static async mapWithLimit\u003CT, R>(\n    items: T[],\n    concurrency: number,\n    fn: (item: T) => Promise\u003CR>\n  ): Promise\u003CR[]> {\n    const results: R[] = [];\n    const executing: Promise\u003Cvoid>[] = [];\n\n    for (const item of items) {\n      const promise = Promise.resolve().then(() => fn(item));\n      results.push(promise);\n      executing.push(promise);\n\n      if (executing.length >= concurrency) {\n        await Promise.race(executing);\n        const completed = executing.findIndex(p => p === promise);\n        if (completed > -1) {\n          executing.splice(completed, 1);\n        }\n      }\n    }\n\n    return Promise.all(results);\n  }\n}\n```\n","## What I do\n- Write async\u002Fawait code in Python and JavaScript\n- Implement concurrent operations\n- Handle async errors properly\n- Use thread pools and process pools\n- Implement producer-consumer patterns\n- Manage async resources with context managers\n- Handle backpressure and rate limiting\n- Debug async code\n\n## When to use me\nWhen implementing asynchronous operations or concurrency patterns.\n\n## Python Asyncio\n```python\nimport asyncio\nimport aiohttp\nfrom typing import List, Optional\nfrom dataclasses import dataclass\nfrom contextlib import asynccontextmanager\n\n\n@dataclass\nclass FetchResult:\n    url: str\n    status: int\n    content: str\n    duration_ms: float\n\n\nclass AsyncFetcher:\n    \"\"\"Concurrent HTTP fetcher with rate limiting.\"\"\"\n    \n    def __init__(\n        self,\n        max_concurrent: int = 10,\n        max_per_second: float = 5.0\n    ) -> None:\n        self.semaphore = asyncio.Semaphore(max_concurrent)\n        self.rate_limiter = AsyncRateLimiter(max_per_second)\n        self.results: List[FetchResult] = []\n    \n    async def fetch(\n        self,\n        session: aiohttp.ClientSession,\n        url: str,\n        timeout: int = 10\n    ) -> FetchResult:\n        \"\"\"Fetch a single URL with rate limiting.\"\"\"\n        async with self.semaphore:\n            async with self.rate_limiter:\n                start = asyncio.get_event_loop().time()\n                \n                try:\n                    async with session.get(\n                        url,\n                        timeout=aiohttp.ClientTimeout(total=timeout)\n                    ) as response:\n                        content = await response.text()\n                        duration = (asyncio.get_event_loop().time() - start) * 1000\n                        \n                        return FetchResult(\n                            url=url,\n                            status=response.status,\n                            content=content,\n                            duration_ms=duration,\n                        )\n                except Exception as e:\n                    return FetchResult(\n                        url=url,\n                        status=0,\n                        content=str(e),\n                        duration_ms=0,\n                    )\n    \n    async def fetch_all(\n        self,\n        urls: List[str],\n        progress_callback: Optional[callable] = None\n    ) -> List[FetchResult]:\n        \"\"\"Fetch multiple URLs concurrently.\"\"\"\n        async with aiohttp.ClientSession() as session:\n            tasks = [self.fetch(session, url) for url in urls]\n            \n            results = []\n            for i, coro in enumerate(asyncio.as_completed(tasks)):\n                result = await coro\n                results.append(result)\n                \n                if progress_callback:\n                    progress_callback(i + 1, len(urls))\n            \n            return results\n\n\nclass AsyncRateLimiter:\n    \"\"\"Token bucket rate limiter for async operations.\"\"\"\n    \n    def __init__(\n        self,\n        rate: float,  # tokens per second\n        capacity: Optional[int] = None\n    ) -> None:\n        self.rate = rate\n        self.capacity = capacity or int(rate)\n        self.tokens = self.capacity\n        self.last_update = asyncio.get_event_loop().time()\n        self.lock = asyncio.Lock()\n    \n    async def acquire(self, tokens: int = 1) -> float:\n        \"\"\"Acquire tokens, wait if necessary. Returns wait time.\"\"\"\n        async with self.lock:\n            now = asyncio.get_event_loop().time()\n            elapsed = now - self.last_update\n            \n            # Add tokens based on elapsed time\n            new_tokens = elapsed * self.rate\n            self.tokens = min(self.capacity, self.tokens + new_tokens)\n            self.last_update = now\n            \n            # Wait for tokens if needed\n            if self.tokens >= tokens:\n                self.tokens -= tokens\n                return 0.0\n            \n            # Calculate wait time\n            needed = tokens - self.tokens\n            wait_time = needed \u002F self.rate\n            self.tokens = 0\n            self.last_update = now + wait_time\n            \n            return wait_time\n    \n    async def __aenter__(self) -> 'AsyncRateLimiter':\n        await self.acquire()\n        return self\n    \n    async def __aexit__(self, *args) -> None:\n        pass\n\n\n@asynccontextmanager\nasync def async_timer(name: str):\n    \"\"\"Context manager for timing async operations.\"\"\"\n    start = asyncio.get_event_loop().time()\n    try:\n        yield\n    finally:\n        duration = (asyncio.get_event_loop().time() - start) * 1000\n        print(f\"{name}: {duration:.2f}ms\")\n```\n\n## Concurrent Processing\n```python\nimport asyncio\nfrom concurrent.futures import ThreadPoolExecutor\nfrom typing import List, TypeVar, Callable, Awaitable\n\n\nT = TypeVar('T')\nR = TypeVar('R')\n\n\nclass ConcurrentProcessor:\n    \"\"\"Process items with configurable concurrency.\"\"\"\n    \n    def __init__(\n        self,\n        max_workers: int = 10,\n        use_processes: bool = False\n    ) -> None:\n        self.max_workers = max_workers\n        self.executor = None\n        self.use_processes = use_processes\n    \n    def __enter__(self) -> 'ConcurrentProcessor':\n        if self.use_processes:\n            self.executor = ProcessPoolExecutor(max_workers=self.max_workers)\n        else:\n            self.executor = ThreadPoolExecutor(max_workers=self.max_workers)\n        return self\n    \n    def __exit__(self, *args) -> None:\n        self.executor.shutdown(wait=True)\n    \n    async def map(\n        self,\n        func: Callable[[T], R],\n        items: List[T],\n        progress_callback: Optional[Callable[[int], None]] = None\n    ) -> List[R]:\n        \"\"\"Map function over items concurrently.\"\"\"\n        loop = asyncio.get_event_loop()\n        tasks = []\n        \n        for item in items:\n            task = loop.run_in_executor(\n                self.executor,\n                func,\n                item\n            )\n            tasks.append(task)\n        \n        results = []\n        for i, future in enumerate(asyncio.as_completed(tasks)):\n            result = await future\n            results.append(result)\n            if progress_callback:\n                progress_callback(i + 1)\n        \n        return results\n    \n    async def map_ordered(\n        self,\n        func: Callable[[T], Awaitable[R]],\n        items: List[T]\n    ) -> List[R]:\n        \"\"\"Map async function preserving order.\"\"\"\n        tasks = [func(item) for item in items]\n        return await asyncio.gather(*tasks)\n\n\nclass ProducerConsumer:\n    \"\"\"Producer-consumer pattern with bounded queue.\"\"\"\n    \n    def __init__(\n        self,\n        max_queue_size: int = 100,\n        max_workers: int = 5\n    ) -> None:\n        self.queue = asyncio.Queue(max_queue_size)\n        self.workers = max_workers\n        self.running = True\n    \n    async def producer(self, items: List[T]) -> None:\n        \"\"\"Produce items for consumption.\"\"\"\n        for item in items:\n            await self.queue.put(item)\n        \n        # Signal completion\n        for _ in range(self.workers):\n            await self.queue.put(None)\n    \n    async def consumer(self, func: Callable[[T], Awaitable[R]]) -> List[R]:\n        \"\"\"Consume items and process them.\"\"\"\n        results = []\n        \n        while self.running:\n            item = await self.queue.get()\n            \n            if item is None:\n                self.queue.task_done()\n                break\n            \n            try:\n                result = await func(item)\n                results.append(result)\n            except Exception as e:\n                print(f\"Error processing item: {e}\")\n            finally:\n                self.queue.task_done()\n        \n        return results\n    \n    async def run(\n        self,\n        items: List[T],\n        func: Callable[[T], Awaitable[R]],\n        progress_callback: Optional[Callable[[int], None]] = None\n    ) -> List[R]:\n        \"\"\"Run the producer-consumer pipeline.\"\"\"\n        results = []\n        \n        async def worker():\n            while True:\n                item = await self.queue.get()\n                if item is None:\n                    break\n                try:\n                    result = await func(item)\n                    results.append(result)\n                finally:\n                    self.queue.task_done()\n        \n        # Start workers\n        workers = [worker() for _ in range(self.workers)]\n        \n        # Start producer\n        producer_task = asyncio.create_task(self.producer(items))\n        \n        # Wait for all\n        await asyncio.gather(producer_task, *workers)\n        \n        return results\n```\n\n## Error Handling\n```python\nimport asyncio\nfrom typing import Optional, TypeVar, Callable\nfrom dataclasses import dataclass\n\n\n@dataclass\nclass AsyncResult:\n    success: bool\n    value: Optional[R] = None\n    error: Optional[Exception] = None\n    duration_ms: float = 0\n\n\nclass AsyncErrorHandler:\n    \"\"\"Handle errors in async code with retries.\"\"\"\n    \n    def __init__(\n        self,\n        max_retries: int = 3,\n        backoff_factor: float = 1.0,\n        exceptions: tuple = (Exception,)\n    ) -> None:\n        self.max_retries = max_retries\n        self.backoff_factor = backoff_factor\n        self.exceptions = exceptions\n    \n    async def execute(\n        self,\n        func: Callable[..., Awaitable[R]],\n        *args,\n        **kwargs\n    ) -> AsyncResult[R]:\n        \"\"\"Execute with retry logic.\"\"\"\n        start = asyncio.get_event_loop().time()\n        \n        for attempt in range(self.max_retries + 1):\n            try:\n                result = await func(*args, **kwargs)\n                duration = (asyncio.get_event_loop().time() - start) * 1000\n                \n                return AsyncResult(\n                    success=True,\n                    value=result,\n                    duration_ms=duration,\n                )\n            \n            except self.exceptions as e:\n                if attempt == self.max_retries:\n                    duration = (asyncio.get_event_loop().time() - start) * 1000\n                    return AsyncResult(\n                        success=False,\n                        error=e,\n                        duration_ms=duration,\n                    )\n                \n                delay = self.backoff_factor * (2 ** attempt)\n                await asyncio.sleep(delay)\n        \n        duration = (asyncio.get_event_loop().time() - start) * 1000\n        return AsyncResult(success=False, duration_ms=duration)\n\n\nclass TimeoutHandler:\n    \"\"\"Handle async operations with timeouts.\"\"\"\n    \n    async def with_timeout(\n        self,\n        coro: Awaitable[R],\n        timeout: float,\n        fallback: Optional[Callable[[], R]] = None\n    ) -> R:\n        \"\"\"Execute with timeout.\"\"\"\n        try:\n            return await asyncio.wait_for(coro, timeout=timeout)\n        except asyncio.TimeoutError:\n            if fallback:\n                return fallback()\n            raise TimeoutError(f\"Operation timed out after {timeout}s\")\n    \n    async def with_individual_timeout(\n        self,\n        tasks: List[asyncio.Task],\n        timeout: float\n    ) -> List[Optional[R]]:\n        \"\"\"Wait for tasks with individual timeouts.\"\"\"\n        results = [None] * len(tasks)\n        \n        for i, task in enumerate(tasks):\n            try:\n                results[i] = await asyncio.wait_for(task, timeout=timeout)\n            except asyncio.TimeoutError:\n                results[i] = None\n            except Exception:\n                results[i] = None\n        \n        return results\n```\n\n## JavaScript Async\n```typescript\n\u002F\u002F Promise utilities\nclass AsyncUtils {\n  static async withTimeout\u003CT>(\n    promise: Promise\u003CT>,\n    timeoutMs: number,\n    fallback?: T\n  ): Promise\u003CT> {\n    return Promise.race([\n      promise,\n      new Promise\u003CT>((_, reject) =>\n        setTimeout(() => {\n          if (fallback !== undefined) {\n            resolve(fallback);\n          } else {\n            reject(new Error(`Timeout after ${timeoutMs}ms`));\n          }\n        }, timeoutMs)\n      ),\n    ]);\n  }\n\n  static async retry\u003CT>(\n    fn: () => Promise\u003CT>,\n    maxRetries: number = 3,\n    delayMs: number = 1000\n  ): Promise\u003CT> {\n    let lastError: Error | null = null;\n\n    for (let i = 0; i \u003C= maxRetries; i++) {\n      try {\n        return await fn();\n      } catch (e) {\n        lastError = e as Error;\n        if (i \u003C maxRetries) {\n          await new Promise(resolve => setTimeout(resolve, delayMs * (i + 1)));\n        }\n      }\n    }\n\n    throw lastError;\n  }\n\n  static async allSettled\u003CT>(\n    promises: Promise\u003CT>[]\n  ): Promise\u003C{ status: 'fulfilled' | 'rejected'; value?: T; reason?: Error }[]> {\n    return Promise.all(\n      promises.map(promise =>\n        promise\n          .then(value => ({ status: 'fulfilled' as const, value }))\n          .catch(reason => ({ status: 'rejected' as const, reason }))\n      )\n    );\n  }\n\n  static async mapWithLimit\u003CT, R>(\n    items: T[],\n    concurrency: number,\n    fn: (item: T) => Promise\u003CR>\n  ): Promise\u003CR[]> {\n    const results: R[] = [];\n    const executing: Promise\u003Cvoid>[] = [];\n\n    for (const item of items) {\n      const promise = Promise.resolve().then(() => fn(item));\n      results.push(promise);\n      executing.push(promise);\n\n      if (executing.length >= concurrency) {\n        await Promise.race(executing);\n        const completed = executing.findIndex(p => p === promise);\n        if (completed > -1) {\n          executing.splice(completed, 1);\n        }\n      }\n    }\n\n    return Promise.all(results);\n  }\n}\n```\n",{"name":5,"license":15,"metadata":36,"description":7,"compatibility":29},{"audience":37,"category":24},"developers","main","2ea764e153842704d24a2e9aa4170441a7f03081",".opencode\u002Fskills\u002Fasync-programming","https:\u002F\u002Fgithub.com\u002FNeuralBlitz\u002FMito","https:\u002F\u002Fgithub.com\u002FNeuralBlitz","nuralnexus.org","Independent Multidisciplinary Researcher, Creative Producer, and AI Systems Architect\r\nAn independent creator and research-driven systems designer.","2026-11-12 03:13:05",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add NeuralBlitz\u002FMito --skill async-programming",{"tool":52,"command":53},"bunx","bunx skills add NeuralBlitz\u002FMito --skill async-programming",{"tool":55,"command":56},"pnpm","pnpm dlx skills add NeuralBlitz\u002FMito --skill async-programming","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FNeuralBlitz\u002FMito\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Fasync-programming\u002FSKILL.md",true,[],[61,77,89,102,110,133],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":31},"01M6HAZSAQK1S27CEZYAYJTQDX","wireless-communications","Wireless systems, mobile networks, and 5G\u002F6G","https:\u002F\u002Fgithub.com\u002FNeuralBlitz\u002FMito\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Fwireless-communications\u002FSKILL.md",[],[68,69,70,71,72,73,74,75,29,76],"communications","wireless communications","wireless","systems","engineering","networks","5G","students","mobile",{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":31},"01M6HAZFX6E8NK3WZWDX5YCKYY","websockets","WebSocket implementation and best practices","https:\u002F\u002Fgithub.com\u002FNeuralBlitz\u002FMito\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Fwebassembly\u002Fwebsockets\u002FSKILL.md",[],[79,84,85,86,29,87,88,27],"websocket implementation","time","implementation","real-time","websocket",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":31},"01M6HAZ6DAXBQ7QHXXM1EM7715","vulnerability-auditing","Vulnerability assessment and auditing","https:\u002F\u002Fgithub.com\u002FNeuralBlitz\u002FMito\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Fvulnerability-auditing\u002FSKILL.md",[],[96,97,98,99,29,100,101],"vulnerability","vulnerability auditing","security","vulnerability assessment","cybersecurity","assessment",{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":31},"01M6HAZ3FKF3CS9Z3J96RVE2ZE","vulnerability-assessment","Finding and assessing security vulnerabilities","https:\u002F\u002Fgithub.com\u002FNeuralBlitz\u002FMito\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Fvue\u002Fvulnerability-assessment\u002FSKILL.md",[],[99,96,101,98,109,29],"vulnerabilities",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":124,"publishedAt":31},"01M6HAYSHM6HKRKEHFP0SGZQX7","vlsi-design","Very-Large-Scale Integration circuit design and semiconductor engineering","https:\u002F\u002Fgithub.com\u002FNeuralBlitz\u002FMito\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Fvlsi-design\u002FSKILL.md",[116,121],{"categoryNo":117,"categoryName":118,"taxonomyType":119,"taxonomyTypeDesc":120},"01JBSEEDCAT000000000000015","视觉设计","SCENARIO","使用场景",{"categoryNo":122,"categoryName":123,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000032","设计师",[125,126,127,128,129,72,130,29,131,75,132],"vlsi design","VLSI","design","hardware","integration","computer","scale","circuit",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":31},"01M6HAYPQ30FFE2JXD7WQJ8R6C","unsupervised","Unsupervised learning concepts","https:\u002F\u002Fgithub.com\u002FNeuralBlitz\u002FMito\u002Fblob\u002Fmain\u002F.opencode\u002Fskills\u002Fvisualization\u002Funsupervised\u002FSKILL.md",[],[135,140,29,141,142,143,144,145],"learning","intelligence","unsupervised learning","machine","concepts","machine-learning"]