Skip to content

Commit 03f447e

Browse files
committed
FIx race
1 parent d166146 commit 03f447e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/test/test_external_inspection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,11 +901,13 @@ def worker_thread(name, barrier, ready_event):
901901
902902
def main_work():
903903
# Do busy work to hold the GIL
904+
sock.sendall(b"working\\n")
904905
count = 0
905906
while count < 100000000:
906907
count += 1
907908
if count % 10000000 == 0:
908909
pass # Keep main thread busy
910+
sock.sendall(b"done\\n")
909911
910912
# Create synchronization primitives
911913
num_threads = 3
@@ -959,8 +961,9 @@ def main_work():
959961
while b"ready" not in response:
960962
response += client_socket.recv(1024)
961963

962-
# Give threads a moment to start their busy work
963-
time.sleep(0.1)
964+
# Wait for the main thread to start its busy work
965+
while b"working" not in response:
966+
response += client_socket.recv(1024)
964967

965968
# Get stack trace with all threads
966969
unwinder_all = RemoteUnwinder(p.pid, all_threads=True)

0 commit comments

Comments
 (0)