Current code uses module attribute which stores value global instead of locally (thread locally). This results in concurrent accesses to overwrite the each other values