fix: remove incorrect await on async generator in Groq streaming#3947
fix: remove incorrect await on async generator in Groq streaming#3947muhammadrashid4587 wants to merge 1 commit intotraceloop:mainfrom
Conversation
_create_async_stream_processor is an async generator (uses yield), so it cannot be awaited. Awaiting it raises: TypeError: object async_generator can't be used in 'await' expression The sync counterpart (_create_stream_processor) correctly returns without await on line 272. This fix makes the async path consistent.
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe async wrapper in the groq instrumentation was modified to return the async stream processor directly instead of awaiting it, adjusting the control flow for streaming responses while maintaining existing exception handling and span lifecycle management. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
awaitkeyword when returning_create_async_stream_processor()in the Groq async instrumentation path_create_async_stream_processoris an async generator (usesyield), soawait-ing it raisesTypeError: object async_generator can't be used in 'await' expressionRoot Cause
Line 355 had
return await _create_async_stream_processor(response, span, event_logger)but the function is an async generator, not a coroutine. The sync counterpart on line 272 correctly usesreturn _create_stream_processor(...)withoutawait.The same pattern is handled correctly in the Ollama and MistralAI instrumentation packages.
Changes
packages/opentelemetry-instrumentation-groq/.../groq/__init__.py— removedawaitfrom the return statementTest Plan
Summary by CodeRabbit