Deconvolute SDK
Advanced Architecture & Best Practices

Asynchronous Execution

Best practices for using the async APIs in high-throughput environments.

When deploying to high-throughput environments (like FastAPI or Aiohttp backends), blocking the Python event loop is a critical failure mode. While LLM API calls and MCP network requests are naturally I/O bound, content scanning is heavily CPU-bound.

All high-level APIs and underlying scanners in Deconvolute support asynchronous execution. Async execution does not change scanner semantics; it changes how the CPU-bound checks are scheduled.

Thread Pool Offloading

If you run a synchronous YARA scan or language detection on a massive document chunk, the Python Global Interpreter Lock (GIL) will block your server from processing other concurrent requests.

To prevent this, Deconvolute's a_ prefixed methods automatically offload these heavy, CPU-bound string matching tasks to an internal thread pool. This allows the main asyncio event loop to yield control and continue handling other network requests while the scan completes in the background.

High-Level APIs

When using async code, llm_guard() automatically uses async scanner methods where available.

For scanning untrusted text asynchronously, use a_scan() instead of scan().

from deconvolute import a_scan

result = await a_scan(doc_chunk)

if not result.safe:
    handle_threat(result)
// TypeScript SDK implementation coming soon

Direct Scanner Execution

If you are using the content scanners directly, each one provides dedicated async methods prefixed with a_.

from deconvolute import SignatureScanner, LanguageScanner, CanaryScanner

sig_scanner = SignatureScanner()
lang_scanner = LanguageScanner()
canary = CanaryScanner()

# Async Signature Check
sig_result = await sig_scanner.a_check(content)

# Async Language Check
lang_result = await lang_scanner.a_check(content)

# Async Canary Lifecycle
secure_prompt, token = canary.inject(prompt)
canary_result = await canary.a_check(model_output, token=token)
cleaned_output = canary.clean(model_output, token)
// TypeScript SDK implementation coming soon

On this page