Python. Finite state machines with a lot of threading. Why?

I wrote this code:
from enum import Enum
import time
import threading

class State(Enum):
 WAITING = 1
 WORKING = 2

def thread(my_func):
 def wrapper(*args, **kwargs):
 my_thread = threading.Thread(target=my_func, args=args, kwargs=kwargs)
my_thread.start()
 return wrapper

@thread
def timeri():
 state = State.WORKING
time.sleep(5)
 print('Finished')
print(state)
 state = State.WAITING

def main():
 state = State.WAITING
 while True:
print(state)
 sms = input()

 if state == State.WAITING:
 print('Hello darling puddin')
timeri()
 elif state == State.WORKING:
 print('I am busy')

if __name__ == '__main__':
 main()

The code is run, write a message, we once welcomed, and then starts a timer that runs 5 seconds and the idea is that these 5 seconds, he should write "I'm busy" (Need is multi threading, so you can write and at the moment it works)

But in the end he always wrote to us Hey, why is this happening?

`State.WAITING
Hi
Hi darling cutie pie
State.WAITING
Hi
Hi darling cutie pie
State.WAITING
Finished work
State.WORKING
Hi
Hi darling cutie pie
State.WAITING
March 20th 20 at 11:39
1 answer
March 20th 20 at 11:41
Solution
The functions timeri and main different instances of the state
Tell me, what is literacy such a problem to implement? - gage.Waters46 commented on March 20th 20 at 11:44

Find more questions by tags Pythonmultithreading