how can I move this code to a function in a module? I have global var 'last_msg' and 'fake'. I was trying use 'global' for 'last_msg' in my function, but it out of scope because function in a module, but 'last_msg' in main scope.
main.py
from module import Timeout
last_msg = {'Foo': 0}
name = 'Foo'
fake = False
timeout = 3
fake = Timeout(fake, name, timeout)
>> NameError: name 'last_msg' is not defined
<>
module.py
def Timeout(fake, name, timeout):
    global last_msg
    if not fake:
        if name not in last_msg:
            last_msg[name] = 0
        if last_msg[name] > 0:
            last_msg[name] -= 1
            fake = True
        else:
            last_msg[name] = timeout
    else:
        if name in last_msg:
            last_msg[name] = 0
    return fake
 
    