0
私は競合状態のPythonコードを持っています。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コードの競合状態を検出できますか?