def __init__(self):
     self.teams = {
         _team: team.Team(_team, utils.games)
         for _team in utils.teams
     }
     self.team_locks = {team: prwlock.RWLock() for team in utils.teams}
     self.game_locks = {game: prwlock.RWLock() for game in utils.games}
     if not os.path.exists(data_dir):
         os.makedirs(data_dir)
     self.number_of_requests = 0
Exemple #2
0
    def __init__(self,
                 filename: str,
                 tree_conf: TreeConf,
                 cache_size: int = 512):
        self._filename = filename
        self._tree_conf = tree_conf
        self._lock = prwlock.RWLock()

        if cache_size == 0:
            self._cache = FakeCache()
        else:
            self._cache = cachetools.LRUCache(maxsize=cache_size)

        self._fd, self._dir_fd = open_file_in_dir(filename)

        self._wal = WAL(filename, tree_conf.page_size)
        if self._wal.needs_recovery:
            self.perform_checkpoint(reopen_wal=True)

        # Get the next available page
        self._fd.seek(0, io.SEEK_END)
        last_byte = self._fd.tell()
        self.last_page = int(last_byte / self._tree_conf.page_size)
        self._freelist_start_page = 0

        # Todo: Remove this, it should only be in Tree
        self._root_node_page = 0
 def __init__(self, server_addr_port, handler_class, disp_ip_addr, is_leader_election, is_clock_sync):
     MultiThreadedHTTPServer.__init__(self, server_addr_port, handler_class)
     Database.__init__(self)
     if is_leader_election:
         LeaderElection.__init__(self, '127.0.0.1:' + str(server_addr_port[1]))
     if is_clock_sync:
         Clock.__init__(self, randint(1, config.DELTA), '127.0.0.1:' + str(server_addr_port[1]))
     self.disp_addr = disp_ip_addr
     self.n_requests_lock = prwlock.RWLock()
 def __init__(self, _pid):
     '''
     :param id: Server Address
     '''
     self.servers = []
     self.logical_id = 0
     self.pid = _pid
     self.queue = []
     self.__rwlock = prwlock.RWLock()
     self.print_mutex = threading.RLock()
     self.processed_reqs = []
Exemple #5
0
    def __init__(self, *order, **arrays):
        self._arrays = arrays

        numArrays = len(arrays)

        self._order = []
        remaining = set(arrays)
        for name in order:
            if name in remaining:
                self._order.append(name)
                remaining.discard(name)
        self._order.extend(sorted(remaining))
            
        c_names = ctypes.ARRAY(ctypes.c_char_p, numArrays)(*[ctypes.c_char_p(x) for x in self._order])
        c_types = ctypes.ARRAY(ctypes.c_char_p, numArrays)(*[ctypes.c_char_p(bytes(arrays[x].dtype)) for x in self._order])
        c_data = ctypes.ARRAY(ctypes.POINTER(None), numArrays)(*[
            arrays[x].ctypes.data_as(ctypes.POINTER(None)) for x in self._order])
        c_lengths = ctypes.ARRAY(ctypes.c_uint64, numArrays)(*[ctypes.c_uint64(numpy.product(arrays[x].shape)) for x in self._order])
        self._locks = [prwlock.RWLock() for x in self._order]
        c_locks = ctypes.ARRAY(ctypes.POINTER(None), numArrays)(*[ctypes.cast(x._lock, ctypes.POINTER(None)) for x in self._locks])
        self._statelock = prwlock.RWLock()
        c_statelock = ctypes.cast(self._statelock._lock, ctypes.POINTER(None))

        self._struct = self.struct(ctypes.c_uint64(numArrays), c_names, c_types, c_data, c_lengths, c_locks, c_statelock, ctypes.c_uint64(0))
Exemple #6
0
 def test_wrong_constant(self):
     prwlock.set_pthread_process_shared(0xbeef)
     with self.assertRaises(OSError):
         prwlock.RWLock()
Exemple #7
0
 def gen():
     while True:
         yield prwlock.RWLock()
Exemple #8
0
 def setUp(self):
     self.rwlock = prwlock.RWLock()