PYTHON/자동화
순차적 thread
yerintil
2019. 12. 19. 16:43
728x90
요소를 찾고 있는 중에 다른 요소를 찾는 과정이 실행되면 안되므로 thread에 lock을 걸어줬다.
버튼을 누르면 함수가 쓰레드로 실행되게 했다.
``` python
lock = threading.Lock() # lock 객체 생성
def basic_test_lock(self):
lock.acquire() # lock
try:
self.result_label.config(text="기본 도구 테스트 진행중")
basic_test(self.version_result_label["text"])
finally:
lock.release() # lock해제 - 다른 쓰레드가 실행가능
self.result_label.config(text="기본 도구 테스트 끝")
basicBtn=Button(window, text="기본",height = 2, width = 7, command = threading.Thread(target=self.basic_test_lock).start)
```