From 1541a10aee89a4d60ddc7c2012a86ea5710c814e Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Tue, 29 Aug 2023 14:19:53 +0900 Subject: [PATCH] Fix relevant tests to use time.monotonic() instead of time.time() --- tests/test_contrib_media.py | 2 +- tests/test_mediastreams.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_contrib_media.py b/tests/test_contrib_media.py index dfe4331c1..3e42f05b9 100644 --- a/tests/test_contrib_media.py +++ b/tests/test_contrib_media.py @@ -323,7 +323,7 @@ async def test_audio_slow_consumer(self): # skip some frames timestamp = 5 * samples_per_frame - await asyncio.sleep(source._start + (timestamp / 8000) - time.time()) + await asyncio.sleep(source._start + (timestamp / 8000) - time.monotonic()) frame1, frame2 = await asyncio.gather(proxy1.recv(), proxy2.recv()) self.assertEqual(frame1.format.name, "s16") diff --git a/tests/test_mediastreams.py b/tests/test_mediastreams.py index c2930421a..0f80a8093 100644 --- a/tests/test_mediastreams.py +++ b/tests/test_mediastreams.py @@ -28,10 +28,10 @@ class VideoPacketStreamTrack(MediaStreamTrack): async def next_timestamp(self) -> Tuple[int, fractions.Fraction]: if hasattr(self, "_timestamp"): self._timestamp += int(VIDEO_PTIME * VIDEO_CLOCK_RATE) - wait = self._start + (self._timestamp / VIDEO_CLOCK_RATE) - time.time() + wait = self._start + (self._timestamp / VIDEO_CLOCK_RATE) - time.monotonic() await asyncio.sleep(wait) else: - self._start = time.time() + self._start = time.monotonic() self._timestamp = 0 return self._timestamp, VIDEO_TIME_BASE