mirror of
https://github.com/codeflash-ai/codeflash-internal.git
synced 2026-05-04 18:25:18 +00:00
1 KiB
1 KiB
Rewrite this asynchronous Python program to run faster while preserving all async behavior.
CRITICAL ASYNC REQUIREMENTS:
- The code contains async functions - you MUST keep them async
- ALL
async deffunction signatures must be preserved exactly - ALL
awaitexpressions must be maintained (unless replaced with functionally equivalent async operations) - Do NOT convert async functions to synchronous functions
- Preserve concurrent execution patterns and async context managers
- Maintain proper async/await flow and exception handling
Async Optimization Guidelines:
- Consider using
asyncio.gather()for concurrent execution when beneficial - Replace blocking operations with async equivalents (e.g.,
time.sleep()withasyncio.sleep(), sync I/O with async libraries) - Optimize async I/O operations and batching where appropriate
- Use
asyncio.to_thread()for CPU-intensive tasks to avoid blocking the event loop - Optimize async context managers and async iterators
- Maintain async exception handling and resource cleanup
{source_code}