Skip to content

Commit

Permalink
instrumentation/asyncio: catch CancelledError exception in tests
Browse files Browse the repository at this point in the history
After a29242f we are re-raising the
CancelledError so we need to catch it on the caller side.

Fix open-telemetry#2688
  • Loading branch information
xrmx committed Jul 10, 2024
1 parent 5ff46ac commit 965fa7e
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def tearDown(self):

def test_cancel(self):
with self._tracer.start_as_current_span("root", kind=SpanKind.SERVER):
asyncio.run(cancellation_create_task())
try:
asyncio.run(cancellation_create_task())
except asyncio.CancelledError:
pass
spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 3)
self.assertEqual(spans[0].context.trace_id, spans[1].context.trace_id)
Expand Down

0 comments on commit 965fa7e

Please sign in to comment.