Context: I am creating a tkinter project that includes face recognition. Because import face_recognition, cv2
takes a long time, to make it more convenient, this has been placed in a thread (I know tkinter doesn't like threads but they are very useful). E.g.
import tkinter
def thread_import ():
global face_recognition, cv2
import face_recognition, cv2
if __name__ == '__main__':
threading.Thread (target = thread_import).start ()
My question is that is there a way to lower the impact of the import. Due to the thread hogging CPU time, my tkinter window can behave unresponsively. I don't mind if it takes slightly longer but I don't really want to go into all the library files to add time.sleep (x)
.
Many thanks in advance.