lock = threading.Lock()
shared_dict = {}

def do_thing(user, value):
    lock.acquire()
try:
    shared_dict[user] = value
finally:
    lock.release()
How would you make this Python Dictionary thread-safe?