Cómo bloquear la escritura en un hilo variable Python

from threading import Lock, Thread
lock = Lock()
g = 0
lock.acquire()
g += 1
lock.release()
Curious Cod