def foo():
    while run:
        print('.', end=' ')
time.sleep(0)
t1 = threading.Thread(target=foo)
t1.start()
time.sleep(2)
run = False
print('run=False')
while True:
    pass
how to share global variables across threads in python?