Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions tests/profiling_v2/collector/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import glob
import os
import threading
import time
from typing import Callable
from typing import List
from typing import Optional
Expand Down Expand Up @@ -1013,6 +1014,10 @@ def test_upload_resets_profile(self) -> None:
with self.collector_class(capture_pct=100):
with self.lock_class(): # !CREATE! !ACQUIRE! !RELEASE! test_upload_resets_profile
pass

# Wait for collector to fully stop before uploading
time.sleep(0.05)

ddup.upload() # pyright: ignore[reportCallIssue]

linenos: LineNo = get_lock_linenos("test_upload_resets_profile", with_stmt=True)
Expand All @@ -1037,11 +1042,18 @@ def test_upload_resets_profile(self) -> None:
)

# Now we call upload() again, and we expect the profile to be empty
num_files_before_second_upload: int = len(glob.glob(self.output_filename + ".*"))

ddup.upload() # pyright: ignore[reportCallIssue]
# parse_newest_profile raises an AssertionError if the profile doesn't
# have any samples
with pytest.raises(AssertionError):
pprof_utils.parse_newest_profile(self.output_filename)

time.sleep(0.05)

num_files_after_second_upload: int = len(glob.glob(self.output_filename + ".*"))

# If a new file was created, it should be empty and parse_newest_profile should raise
if num_files_before_second_upload != num_files_after_second_upload:
with pytest.raises(AssertionError):
pprof_utils.parse_newest_profile(self.output_filename)


class TestThreadingLockCollector(BaseThreadingLockCollectorTest):
Expand Down
Loading