Skip to content

Commit ba86364

Browse files
committed
Make threaded print threadsafe
1 parent 34371d7 commit ba86364

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

test/cases/use_threads.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
import instrumentation2
55

66

7+
lock = threading.Lock()
8+
9+
710
def worker(id, func):
8-
print("Thread %s started" % id)
11+
with lock:
12+
print("Thread %s started" % id)
913
# Use a random delay to add non-determinism to the output
1014
time.sleep(random.uniform(0.01, 0.9))
1115
func()

0 commit comments

Comments
 (0)