Thread Lock

Saw this in MIT-PITT-RW code.

Was briefly introduced this in CS247 with C++ multithreading. However, I don’t know much about it.

from threading import Lock
self._lock = Lock()
 
def run_detection(self):
	...
	with self._lock:
		if self.pts is not None:
			pts = self.pts.copy()
			# intensity = self.intensity.copy()
		else:
			pts = None
	if pts is None:
		return