You should not use
Just to show some basic stuff with threading that may help.
Without threading will now
global
is terrible in almost all cases,and using threading dos not make it better.Just to show some basic stuff with threading that may help.
from threading import Thread def func1(): print(f'Working') def func2(): print("Working") if __name__ == '__main__': Thread(target=func1).start() Thread(target=func2).start()If want argument to the function is done like(no value from global namespace) this with threading.
from threading import Thread from time import sleep def func1(name): sleep(5) print(f'Working {name}') def func2(): print("Working") if __name__ == '__main__': name = 'Kent' Thread(target=func1, args=(name,)).start() Thread(target=func2).start()See that
working
print immediately.Without threading will now
sleep
block.from threading import Thread from time import sleep def func1(name): sleep(5) print(f'Working {name}') def func2(): print("Working") if __name__ == '__main__': name = 'Kent' func1(name) func2()