#async

24 snippets tagged with #async

typescriptbeginner

Async Error Handler Wrapper

Higher-order function that wraps async Express route handlers and forwards rejected promises to error middleware.

Best for: Express route error handling

#express#async
typescriptadvanced

Node.js In-Memory Task Queue

A simple in-memory task queue with concurrency control, retries, and priority support.

Best for: Rate-limited API call processing

#nodejs#queue
typescriptintermediate

Event Loop and Timers

Understand Node.js event loop phases with setTimeout, setInterval, setImmediate, and process.nextTick.

Best for: Understanding async execution order

#nodejs#event-loop
typescriptintermediate

Promise Concurrency Patterns

Master Promise.all, allSettled, race, any — parallel execution with error handling and timeouts.

Best for: Parallel API calls with error handling

#nodejs#promise
typescriptadvanced

AbortController for Cancellation

Cancel async operations with AbortController: fetch requests, timers, streams, and custom operations.

Best for: Request timeout handling

#nodejs#abort
typescriptadvanced

Async Iterators for Stream Processing

Process streams and async data sources with for-await-of loops and custom async iterators in Node.js.

Best for: Paginated API data consumption

#nodejs#async-iterator
typescriptintermediate

Semaphore for Concurrency Limiting

Control concurrent async operations with a semaphore pattern: rate limiting, connection pooling, and batch processing.

Best for: API rate limiting

#nodejs#concurrency
typescriptadvanced

Promise Queue with Concurrency Limit

A queue that processes async tasks with a configurable concurrency limit to prevent resource exhaustion.

Best for: Rate-limited API calls

#async#concurrency
typescriptintermediate

useFetch — Generic Data Fetching Hook

Custom React hook for data fetching with loading, error, and refetch states using the Fetch API.

Best for: API data fetching

#hooks#fetch
typescriptintermediate

useAsync Hook for Promise Management

Manage async operations with loading, error, and data states using a reusable hook pattern.

Best for: Data fetching with status tracking

#react#hooks
pythonintermediate

Async HTTP Client with httpx

Production-ready async HTTP client using httpx with retries, timeouts, and connection pooling.

Best for: REST API consumption

#httpx#async
pythonintermediate

asyncio.gather Concurrent Tasks

Run multiple async operations concurrently with asyncio.gather and proper error handling.

Best for: Parallel API calls

#asyncio#concurrency
pythonintermediate

HTTPX Async Client with Retry

Make async HTTP requests with HTTPX featuring timeout config, retry logic, and response streaming.

Best for: API integrations

#httpx#async
pythonintermediate

Async OpenAI Client in Python

Use the AsyncOpenAI client with asyncio to run concurrent chat completions without blocking.

Best for: concurrent LLM calls

#openai#async
pythonadvanced

Async AI Inference with Celery

Offload slow LLM inference to Celery background workers with Redis as broker and result backend.

Best for: async AI processing

#celery#async
pythonadvanced

Parallel Tool Calls with OpenAI

Execute multiple tool calls in parallel when OpenAI returns multiple function calls in one response.

Best for: parallel function calls

#openai#parallel
pythonadvanced

SQLAlchemy Async Session with asyncpg

Use SQLAlchemy 2.0 async sessions with asyncpg for non-blocking database access in async pipelines.

Best for: async web services

#sqlalchemy#async
pythonintermediate

Async ETL Pipeline with asyncio

Run concurrent data fetches and transformations using asyncio.gather for high-throughput pipelines.

Best for: concurrent API ingestion

#asyncio#async
javaintermediate

CompletableFuture — Async Programming

Chain async operations with CompletableFuture: thenApply, thenCompose, allOf, and exception handling.

Best for: Parallel API calls to multiple services

#java#async
javaintermediate

Spring Boot — Application Events

Use Spring's event system for decoupled communication: custom events, async listeners, and ordering.

Best for: Decoupled event-driven service communication

#spring-boot#events
javaadvanced

CompletableFuture Combinators — allOf, anyOf, compose

Compose async operations with CompletableFuture: allOf, anyOf, thenCombine, handle, and timeout.

Best for: Aggregating results from multiple microservices

#java#async
kotlinintermediate

Coroutines — launch, async, and Structured Concurrency

Write concurrent code with Kotlin coroutines: launch, async/await, structured concurrency, and dispatchers.

Best for: Parallel API calls in backend services

#kotlin#coroutines
scalaintermediate

Futures and Async Programming

Use Scala Futures for async operations: map, flatMap, recover, sequence, and race patterns.

Best for: Asynchronous API calls

#scala#futures
scalaintermediate

Future Async Patterns

Work with Scala Futures: composition, error handling, timeout, retry, and parallel execution.

Best for: Asynchronous API calls

#scala#future