def setUp(self): """Test setup.""" self.v_value = 0 from readerwriterlock import rwlock self.c_rwlock_instance = [ rwlock.RWLockRead(), rwlock.RWLockWrite(), rwlock.RWLockFair() ]
def __init__(self, application): self.application = application self.server = None self.running = False self.clients = {} # create the socket AF_INET states this is an Ipv4 Socket, SOCK_STREAM states this is a TCP socket self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.port = 3002 self.address = '127.0.0.1' self.clients_lock = rwlock.RWLockRead()
class ServiceRegistry(object): config_path = attr.ib(default=NODE_CONFIG_FILE) _config = attr.ib(default={}) _lock = attr.ib(default=rwlock.RWLockRead()) def config_exists(self): return os.path.exists(self.config_path) def load_config(self): with open(self.config_path) as file: with self._lock.gen_wlock(): self._config = yaml.load(file, Loader=yaml.FullLoader) return True def get_config(self): with self._lock.gen_rlock(): return self._config
def __init__(self, application): self.running = False self.application = application self.current_view = None self.fs_view = FileSystemView(self) self.main_view = MainView(self) self.ps_view = ProcessView(self) self.interacting = False self.waiting_desktop_images = False self.shell_active = False self.client_id = None self.client_lock = rwlock.RWLockRead()
def __init__(self, condition: Condition): self.has_reading = False self.condition = condition self.data = list() self.rwlock = rwlock.RWLockRead()
app = Flask(__name__) api = Api(app) ''' Map of the entire storeage in the current DataNode i.e BlockData Structure: { "blockID": { filename: "filename1", }, "blockID": { filename: "filename2", }, } ''' gLock = rwlock.RWLockRead() BlockList = None DATA_DIR = None TMP_DIR = "./tmp" nameNodeIP = "" def storeBlockData(filename, data): tmpf = tempfile.NamedTemporaryFile(dir=TMP_DIR, mode="wb", delete=False) tmpf.write(data) tmpf.flush() tmpf.close() os.rename(tmpf.name, os.path.join(DATA_DIR, filename)) def getBlockData(filename):
import random import threading import time import requests import constants from readerwriterlock import rwlock import werkzeug.exceptions as HTTPStatus from flask import Flask, abort from flask_restful import Api, Resource, request from collections import Counter app = Flask(__name__) api = Api(app) gLock = rwlock.RWLockRead() LastSeenDNs = {} ''' Map of the entire filesystem i.e FSData Structure: { <DNID> : { "BlockList": { <blockid>: {"size" <length-in-bytes>} }, "AvailableCapacity": <length-in-bytes>, "TotalCapacity": <length-in-bytes> }, <DNID> : { "BlockList": { <blockid>: {"size" <length-in-bytes>}
def __init__(self): self.data = {} self.counter = randint(1000,10000) self.db_lock = rwlock.RWLockRead() self.counter_lock = rwlock.RWLockRead()
def __init__(self, noCompression, maxFileSize, name, path, files, index, # readMeter, # writeMeter, # sizeGauge, logger, items = None, head = None, headId = None, tailId = None, itemOffset = None, headBytes = None ): """ Constructs a :class:`FreezerTable` object. Normally, this is called internally. Args: noCompression: A boolean, indicates whether or not the table data is compressed. maxFileSize : A Integer, indicates the maximum size of a table blob file. name : A string, specifies the name of the table. path : A string, specifies the path to the folder that stores the Freezer table files. files : A dict, maps from the file number to the opened file. index : A file, opened index file. logger : A logger, got from python built-in ``logging`` module. items : Internal state, defaults to `None`. head : Internal state, defaults to `None`. headId : Internal state, defaults to `None`. tailId : Internal state, defaults to `None`. itemOffset : Internal state, defaults to `None`. headBytes : Internal state, defaults to `None`. """ self.items = items self.noCompression = noCompression self.maxFileSize = maxFileSize self.name = name self.path = path self.head = head self.files = files self.headId = headId self.tailId = tailId self.index = index self.itemOffset = itemOffset self.headBytes = headBytes # self.readMeter = readMeter # self.writeMeter = writeMeter # self.sizeGauge = sizeGauge self.logger = logger self.lock = rwlock.RWLockRead()