def __init__(self): # Used for plotting Bucket status table self.itemCount = 0 self.diskUsed = 0 self.memUsed = 0 self.ram = 0 self.manifest_uid = 0 self.expected_item_count = 0 self.mutex = Lock() # Used to manage Bucket stats task self.stats_task = {"count": 0, "object": None, "lock": Lock()}
class BucketStats(object): def __init__(self): # Used for plotting Bucket status table self.itemCount = 0 self.diskUsed = 0 self.memUsed = 0 self.ram = 0 self.manifest_uid = 0 self.expected_item_count = 0 self.mutex = Lock() # Used to manage Bucket stats task self.stats_task = {"count": 0, "object": None, "lock": Lock()} def increment_manifest_uid(self): """ Increments the manifest UID of bucket object. :return: None """ # Uses Lock to safely update the uid during threaded execution self.mutex.acquire() self.manifest_uid += 1 self.mutex.release() def manage_task(self, operation, task_manager, cluster=None, bucket=None, monitor_stats=list(), sleep=1): task_pkg = Jython_tasks.task if operation == "start": self.stats_task["lock"].acquire() if self.stats_task["object"] is None: self.stats_task["object"] = task_pkg.PrintBucketStats( cluster, bucket, monitor_stats=monitor_stats, sleep=sleep) task_manager.add_new_task(self.stats_task["object"]) self.stats_task["count"] += 1 self.stats_task["lock"].release() elif operation == "stop": self.stats_task["lock"].acquire() if self.stats_task["count"] == 1: self.stats_task["object"].end_task() task_manager.get_task_result(self.stats_task["object"]) self.stats_task["object"] = None self.stats_task["count"] -= 1 self.stats_task["lock"].release()
def __init__(self, value=1, verbose=None): assert value >= 0, "Semaphore initial value must be >= 0" _Verbose.__init__(self, verbose) self.__cond = Condition(Lock()) self.__value = value
def __init__(self, verbose=None): _Verbose.__init__(self, verbose) self.__cond = Condition(Lock()) self.__flag = False
def __init__(self, value=1, verbose=None): if value < 0: raise ValueError("Semaphore initial value must be >= 0") _Verbose.__init__(self, verbose) self.__cond = Condition(Lock()) self.__value = value