0
경쟁 조건이있는 파이썬 코드가 있습니다.valgrind를 Python 코드와 함께 사용하여 경쟁 조건을 감지하려면 어떻게해야합니까?
import threading
class Counter:
def __init__(self):
self.x = 0
def incr(self):
self.x += 1
def __str__(self):
return str(self.x)
x = Counter()
class T(threading.Thread):
def run(self):
for i in range(100000):
x.incr()
t1 = T()
t2 = T()
t1.start()
t2.start()
t1.join()
t2.join()
print(x)
나는 그것을 감지하기 위해 valgrind를 사용하려고합니다.
valgrind --tool=helgrind --suppressions=valgrind-python.supp \python -E -tt ./1.py
0 errors from 0 contexts (suppressed: 9 from 9)
valgrind를 사용하여 Python 코드의 경쟁 조건을 감지 할 수 있습니까?