File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
tests/profiling_v2/collector Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 22import glob
33import os
44import threading
5+ import time
56from typing import Callable
67from typing import List
78from typing import Optional
@@ -1013,6 +1014,10 @@ def test_upload_resets_profile(self) -> None:
10131014 with self .collector_class (capture_pct = 100 ):
10141015 with self .lock_class (): # !CREATE! !ACQUIRE! !RELEASE! test_upload_resets_profile
10151016 pass
1017+
1018+ # Wait for collector to fully stop before uploading
1019+ time .sleep (0.05 )
1020+
10161021 ddup .upload () # pyright: ignore[reportCallIssue]
10171022
10181023 linenos : LineNo = get_lock_linenos ("test_upload_resets_profile" , with_stmt = True )
@@ -1037,11 +1042,18 @@ def test_upload_resets_profile(self) -> None:
10371042 )
10381043
10391044 # Now we call upload() again, and we expect the profile to be empty
1045+ num_files_before_second_upload : int = len (glob .glob (self .output_filename + ".*" ))
1046+
10401047 ddup .upload () # pyright: ignore[reportCallIssue]
1041- # parse_newest_profile raises an AssertionError if the profile doesn't
1042- # have any samples
1043- with pytest .raises (AssertionError ):
1044- pprof_utils .parse_newest_profile (self .output_filename )
1048+
1049+ time .sleep (0.05 )
1050+
1051+ num_files_after_second_upload : int = len (glob .glob (self .output_filename + ".*" ))
1052+
1053+ # If a new file was created, it should be empty and parse_newest_profile should raise
1054+ if num_files_before_second_upload != num_files_after_second_upload :
1055+ with pytest .raises (AssertionError ):
1056+ pprof_utils .parse_newest_profile (self .output_filename )
10451057
10461058
10471059class TestThreadingLockCollector (BaseThreadingLockCollectorTest ):
You can’t perform that action at this time.
0 commit comments