#!/bin/python from threading import Lock class UwuCounter: ''' Class defined to be a threadsafe Atomic Counter for UwUs. Original concept and code for this idea was borrowed from a GitHub Gist by user benhoyt https://gist.github.com/benhoyt/8c8a8d62debe8e5aa5340373f9c509c7 ''' def __init__(self, initial=0): super().__init__() self.curval = initial self._lock = Lock() def increment(self, num=1): with self._lock: self.curval += num return self.curval