MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / _process_sync_generator

Function _process_sync_generator

agentops/sdk/decorators/utility.py:38–49  ·  view source on GitHub ↗

Process a synchronous generator and manage its span lifecycle

(span: trace.Span, generator: types.GeneratorType)

Source from the content-addressed store, hash-verified

36
37
38def _process_sync_generator(span: trace.Span, generator: types.GeneratorType):
39 """Process a synchronous generator and manage its span lifecycle"""
40 # Ensure span context is attached to the generator context
41 context_api.attach(trace.set_span_in_context(span))
42
43 # Yield from the generator while maintaining span context
44 yield from generator
45
46 # End the span when generator is exhausted
47 span.end()
48 # No detach because of OpenTelemetry issue #2606
49 # Context will be detached during garbage collection
50
51
52async def _process_async_generator(span: trace.Span, context_token: Any, generator: types.AsyncGeneratorType):

Callers 1

wrapperFunction · 0.90

Calls 1

endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…