Skip to content

Commit 3f54056

Browse files
authored
Merge branch 'main' into fix/logging-force-flush-timeout-uniformity
2 parents 66fc18b + b1f499b commit 3f54056

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

opentelemetry-sdk/tests/shared_internal/test_batch_processor.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,16 @@ def test_shutdown_allows_1_export_to_finish(self, batch_processor_class, telemet
274274
processor._batch_processor.emit(telemetry)
275275
processor._batch_processor.emit(telemetry)
276276
processor._batch_processor.emit(telemetry)
277-
before = time.time()
277+
before = time.monotonic()
278278
processor._batch_processor.shutdown(timeout_millis=3000)
279-
# Shutdown does not kill the thread.
280-
assert processor._batch_processor._worker_thread.is_alive() is True
281279

282-
after = time.time()
280+
after = time.monotonic()
283281
assert after - before < 3.3
284-
# Thread will naturally finish after a little bit.
285-
time.sleep(0.1)
282+
283+
# The exporter shutdown interrupts the in-progress export. Depending
284+
# on thread scheduling, the worker may stop before or shortly after
285+
# shutdown() returns.
286+
processor._batch_processor._worker_thread.join(timeout=1)
286287
assert processor._batch_processor._worker_thread.is_alive() is False
287288
# Expect the second call to be interrupted by shutdown, and the third call to never be made.
288289
assert exporter.sleep_interrupted is True

0 commit comments

Comments
 (0)