Spaces:
Sleeping
Sleeping
import os | |
import pandas as pd | |
from threading import Lock | |
class UserID: | |
def __init__(self): | |
self.lock = Lock() | |
self.counter = 0 | |
if os.path.exists('global_variable.csv'): | |
df = pd.read_csv('global_variable.csv') | |
self.counter = df['value'][0] | |
def increment(self): | |
with self.lock: | |
self.counter += 1 | |
df = pd.DataFrame({'value': [self.counter]}) | |
df.to_csv('global_variable.csv', index=False) | |
return self.counter |