mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 06:33:41 +00:00
test(core): increase delta_time for flaky test (#34982)
This regularly flaked
This commit is contained in:
@@ -102,15 +102,12 @@ async def test_queue_for_streaming_via_sync_call() -> None:
|
||||
|
||||
for item in items:
|
||||
delta_time = item["receive_time"] - item["produce_time"]
|
||||
# Allow a generous 10ms of delay
|
||||
# The test is meant to verify that the producer and consumer are running in
|
||||
# parallel despite the fact that the producer is running from another thread.
|
||||
# abs_tol is used to allow for some delay in the producer and consumer
|
||||
# due to overhead.
|
||||
# To verify that the producer and consumer are running in parallel, we
|
||||
# expect the delta_time to be smaller than the sleep delay in the producer
|
||||
# * # of items = 30 ms
|
||||
assert math.isclose(delta_time, 0, abs_tol=0.020) is True, (
|
||||
# The test verifies that the producer and consumer are running in parallel
|
||||
# despite the producer running from another thread via asyncio.to_thread.
|
||||
# Cross-thread communication has overhead that varies with system load,
|
||||
# so we use a tolerance of 150ms. This still proves parallelism because
|
||||
# serial execution would show deltas of 200ms+ (the sleep interval).
|
||||
assert math.isclose(delta_time, 0, abs_tol=0.15) is True, (
|
||||
f"delta_time: {delta_time}"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user