OS: Windows
Python version: Python3.8
SDK version: main
API version: main
What happened?
================================== FAILURES ===================================
_______ TestBatchSpanProcessor.test_batch_span_processor_reset_timeout ________
self = <tests.trace.export.test_export.TestBatchSpanProcessor testMethod=test_batch_span_processor_reset_timeout>
@mark.skipif(
python_implementation() == "PyPy" and system() == "Windows",
reason="This test randomly fails in Windows with PyPy",
)
def test_batch_span_processor_reset_timeout(self):
"""Test that the scheduled timeout is reset on cycles without spans"""
spans_names_list = []
export_event = threading.Event()
my_exporter = MySpanExporter(
destination=spans_names_list,
export_event=export_event,
export_timeout_millis=50,
)
span_processor = export.BatchSpanProcessor(
my_exporter,
schedule_delay_millis=50,
)
with mock.patch.object(span_processor.condition, "wait") as mock_wait:
resource = Resource.create({})
_create_start_and_end_span("foo", span_processor, resource)
self.assertTrue(export_event.wait(2))
# give some time for exporter to loop
# since wait is mocked it should return immediately
time.sleep(0.1)
mock_wait_calls = list(mock_wait.mock_calls)
# find the index of the call that processed the singular span
for idx, wait_call in enumerate(mock_wait_calls):
_, args, __ = wait_call
if args[0] <= 0:
after_calls = mock_wait_calls[idx + 1 :]
break
self.assertTrue(
> all(args[0] >= 0.05 for _, args, __ in after_calls)
)
E UnboundLocalError: local variable 'after_calls' referenced before assignment
Describe your environment
OS: Windows Python version: Python3.8 SDK version: main API version: main
What happened?
Steps to Reproduce
Run in CI https://github.com/open-telemetry/opentelemetry-python/actions/runs/10041807138/job/27750740610
Expected Result
Test pass every time
Actual Result
Some runs test don't pass
Additional context
No response
Would you like to implement a fix?
None