Spaces:
Sleeping
Sleeping
File size: 529 Bytes
8092894 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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 |