def client_df7(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Blocker], details=server_name, resolver={Blocker: blocker_merge_func}) send_q.put(df.details) #print ("Client at start:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C1 #print ("Waiting for C1") server_ready.wait() server_ready.clear() #print ("Client after waiting for server first time.:", df.versioned_heap.version_graph.nodes.keys()) # Pull from the server. df.pull() #print ("Client after first pull:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() blockers = df.read_all(Blocker) assert (1 == len(blockers)) b1 = blockers[0] assert (b1.prop == 1) #print ("Setting S1") # Setting point S1 client_ready.set() b1.prop = 10 assert (b1.prop == 10) df.commit() #print ("Client after first modification:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C2 #print ("Waiting for C2") server_ready.wait() server_ready.clear() #print ("Client after waiting for server:", df.versioned_heap.version_graph.nodes.keys()) df.push() #print ("Client after pushing:", df.versioned_heap.version_graph.nodes.keys()) # Setting point S2 #print ("Setting S2") client_ready.set() # Waiting at point c3 #print ("Waiting for C3") server_ready.wait() server_ready.clear() df.pull() #print ("Client after pulling second time:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() assert (b1.prop == 10) b1.prop = 5 df.commit() df.push() # Setting point S3 #print ("Setting S3") client_ready.set() # Waiting at point c4 #print ("Waiting for C4") server_ready.wait() server_ready.clear()
def client_df7(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Blocker], details=server_name) send_q.put(df.details) #print ("Client at start:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C1 #print ("Waiting for C1") server_ready.wait() server_ready.clear() #print ("Client after waiting for server first time.:", df.versioned_heap.version_graph.nodes.keys()) # Pull from the server. df.pull() #print ("Client after first pull:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() blockers = df.read_all(Blocker) assert (1 == len(blockers)) b1 = blockers[0] assert (b1.prop == 1) #print ("Setting S1") # Setting point S1 client_ready.set() b1.prop = 10 assert (b1.prop == 10) df.commit() #print ("Client after first modification:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C2 #print ("Waiting for C2") server_ready.wait() server_ready.clear() #print ("Client after waiting for server:", df.versioned_heap.version_graph.nodes.keys()) df.push() #print ("Client after pushing:", df.versioned_heap.version_graph.nodes.keys()) # Setting point S2 #print ("Setting S2") client_ready.set() # Waiting at point c3 #print ("Waiting for C3") server_ready.wait() server_ready.clear() df.pull() #print ("Client after pulling second time:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() assert (b1.prop == 10) b1.prop = 5 df.commit() df.push() # Setting point S3 #print ("Setting S3") client_ready.set() # Waiting at point c4 #print ("Waiting for C4") server_ready.wait() server_ready.clear()
def client_df4(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Counter], details=server_name, resolver={Counter: counter_merge_func}) send_q.put(df.details) #print ("Client at start:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C1 #print ("Waiting for C1") server_ready.wait() server_ready.clear() #print ("Client after waiting for server first time.:", df.versioned_heap.version_graph.nodes.keys()) # Pull from the server. df.pull() #print ("Client after first pull:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() counters = df.read_all(Counter) cars = df.read_all(Car) assert (1 == len(counters)) assert (0 == len(cars)) c1 = counters[0] assert (c1.count == 1) #print ("Setting S1") # Setting point S1 client_ready.set() c1.count += 1 assert (c1.count == 2) df.commit() #print ("Client after first modification:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C2 #print ("Waiting for C2") server_ready.wait() server_ready.clear() #print ("Client after waiting for server:", df.versioned_heap.version_graph.nodes.keys()) df.push() #print ("Client after pushing:", df.versioned_heap.version_graph.nodes.keys()) # Setting point S2 #print ("Setting S2") client_ready.set() # Waiting at point c3 #print ("Waiting for C3") server_ready.wait() server_ready.clear() df.pull() #print ("Client after pulling second time:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() assert (c1.count == 3) # Setting point S3 #print ("Setting S3") client_ready.set()
def client_df4(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Counter], details=server_name) send_q.put(df.details) #print ("Client at start:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C1 #print ("Waiting for C1") server_ready.wait() server_ready.clear() #print ("Client after waiting for server first time.:", df.versioned_heap.version_graph.nodes.keys()) # Pull from the server. df.pull() #print ("Client after first pull:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() counters = df.read_all(Counter) cars = df.read_all(Car) assert (1 == len(counters)) assert (0 == len(cars)) c1 = counters[0] assert (c1.count == 1) #print ("Setting S1") # Setting point S1 client_ready.set() c1.count += 1 assert (c1.count == 2) df.commit() #print ("Client after first modification:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C2 #print ("Waiting for C2") server_ready.wait() server_ready.clear() #print ("Client after waiting for server:", df.versioned_heap.version_graph.nodes.keys()) df.push() #print ("Client after pushing:", df.versioned_heap.version_graph.nodes.keys()) # Setting point S2 #print ("Setting S2") client_ready.set() # Waiting at point c3 #print ("Waiting for C3") server_ready.wait() server_ready.clear() df.pull() #print ("Client after pulling second time:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() assert (c1.count == 3) # Setting point S3 #print ("Setting S3") client_ready.set()
def server_app(dataframe: Dataframe, env_class: Type[BaseEnvironment], observation_type: Type, args: dict, whitelist: list = None, ready_event: Event = None): timeout = Timeout() fr: FrameRateKeeper = FrameRateKeeper(max_frame_rate=args['tick_rate']) # Keep track of each player and their associated observations observation_dataframes: Dict[int, Dataframe] = {} observations: Dict[int, _Observation] = {} players: Dict[int, Player] = {} # Function to help push all observations def push_observations(): for df in observation_dataframes.values(): df.commit() # Add the server state to the master dataframe server_state = ServerState(env_class.__name__, args["config"], env_class.observation_names()) dataframe.add_one(ServerState, server_state) dataframe.commit() # Function to help clean up server if it ever needs to shutdown def close_server(message: str): server_state.terminal = True logger.error(message) dataframe.commit() sleep(5) # Create the environment and start the server env: BaseEnvironment = env_class(args["config"]) logger.info("Waiting for enough players to join ({} required)...".format(env.min_players)) # Add whitelist support, players will be rejected if their key does not match the expected keys whitelist = [] if whitelist is None else whitelist whitelist_used = len(whitelist) > 0 whitelist_connected = {key: False for key in whitelist} # If we were created by some server manager, inform them we are ready for players if ready_event is not None: ready_event.set() # ----------------------------------------------------------------------------------------------- # Wait for all players to connect # ----------------------------------------------------------------------------------------------- fr.start_timeout(timeout.connect) while len(players) < env.min_players: if fr.tick(): close_server("Game could not find enough players. Shutting down game server.") return 1 dataframe.sync() new_players: Dict[int, Player] = dict((p.pid, p) for p in dataframe.read_all(Player)) # Any players that have connected by have not been acknowledged yet for new_id in new_players.keys() - players.keys(): name = new_players[new_id].name auth_key = new_players[new_id].authentication_key if whitelist_used and auth_key not in whitelist_connected: logger.info("Player tried to join with invalid authentication_key: {}".format(name)) dataframe.delete_one(Player, new_id) del new_players[new_id] continue if whitelist_used and whitelist_connected[auth_key]: logger.info("Player tried to join twice with the same authentication_key: {}".format(name)) dataframe.delete_one(Player, new_id) del new_players[new_id] continue logger.info("New player joined with name: {}".format(name)) # Create new observation dataframe for the new player obs_df = Dataframe("{}_observation".format(name), [observation_type]) obs = observation_type(new_id) obs_df.add_one(observation_type, obs) # Add the dataframes to the database observation_dataframes[new_id] = obs_df observations[new_id] = obs whitelist_connected[auth_key] = True # If any players that we have added before have dropped out for remove_id in players.keys() - new_players.keys(): logger.info("Player {} has left.".format(players[remove_id].name)) auth_key = players[remove_id].authentication_key whitelist_connected[auth_key] = False del observations[remove_id] del observation_dataframes[remove_id] players = new_players # ----------------------------------------------------------------------------------------------- # Create all of the player data and wait for the game to begin # ----------------------------------------------------------------------------------------------- logger.info("Finalizing players and setting up new environment.") server_state.server_no_longer_joinable = True # Create the initial state for the environment and push it if enabled state, player_turns = env.new_state(num_players=len(players)) if not args["observations_only"] and env.serializable(): server_state.serialized_state = env.serialize_state(state) # Set up each player for i, (pid, player) in enumerate(players.items()): # Add the initial observation to each player observations[pid].set_observation(env.state_to_observation(state=state, player=i)) # Finalize each player by giving it a player number and a port for the dataframe player.finalize_player(number=i, observation_port=observation_dataframes[pid].details[1]) if i in player_turns: player.turn = True # Push all of the results to the player players_by_number: Dict[int, Player] = dict((p.number, p) for p in players.values()) push_observations() dataframe.sync() # Wait for all players to be ready fr.start_timeout(timeout.start) while not all(player.ready_for_start for player in players.values()): if fr.tick(): close_server("Players have dropped out between entering the game and starting the game.") return 2 dataframe.checkout() # ----------------------------------------------------------------------------------------------- # Primary game loop # ----------------------------------------------------------------------------------------------- logger.info("Game started...") terminal = False winners = None dataframe.commit() fr.start_timeout(timeout.move) while not terminal: # Wait for a frame to tick move_timeout = fr.tick() # Get new data dataframe.checkout() # Get the player dataframes of the players who's turn it is right now current_players: List[Player] = [p for p in players.values() if p.number in player_turns] current_actions: List[str] = [] ready = args['realtime'] or move_timeout or all(p.ready_for_action_to_be_taken for p in current_players) if not ready: continue # Queue up each players action if it is legal # If the player failed to respond in time, we will simply execute the previous action # If it is invalid, we will pass in a blank string for player in current_players: if player.action == '' or env.is_valid_action(state=state, player=player.number, action=player.action): current_actions.append(player.action) else: logger.info("Player #{}, {}'s, action of {} was invalid, passing empty string as action" .format(player.number, player.name, player.action)) current_actions.append('') # Execute the current move state, player_turns, rewards, terminal, winners = ( env.next_state(state=state, players=player_turns, actions=current_actions) ) # Update true state if enabled if not args["observations_only"] and env.serializable(): server_state.serialized_state = env.serialize_state(state) # Update the player data from the previous move. for player, reward in zip(current_players, rewards): player.reward_from_last_turn = float(reward) player.ready_for_action_to_be_taken = False player.turn = False # Tell the new players that its their turn and provide observation for player_number in player_turns: player = players_by_number[player_number] observations[player.pid].set_observation(env.state_to_observation(state=state, player=player_number)) player.turn = True if terminal: server_state.terminal = True server_state.winners = dill.dumps(winners) for player_number in winners: players_by_number[player_number].winner = True logger.info("Player: {} won the game.".format(winners)) push_observations() dataframe.commit() fr.start_timeout(timeout.move) # ----------------------------------------------------------------------------------------------- # Clean up after game # ----------------------------------------------------------------------------------------------- for player in players.values(): player.turn = True dataframe.commit() dataframe.push() # TODO| The code below attempts to ensure that the players have the final state of the game before the server quits. # TODO| However, an error is thrown when players disconnect during the checkout. If this snippet was removed, # TODO| players would have a similar error when the server would quit while they are pulling. # TODO| May need to talk to Rohan about cleanly exiting this kind of situation. # TODO| It would also be great if we could instead properly confirm that recipients got a message. fr.start_timeout(timeout.end) for player in players.values(): while not player.acknowledges_game_over and not fr.tick(): dataframe.checkout() rankings = env.compute_ranking(state, list(range(len(players))), winners) ranking_dict = {players_by_number[number].name: ranking for number, ranking in rankings.items()} logger.info("Game has ended. Player {} is the winner.".format([key for key, value in ranking_dict.items() if value == 0])) return ranking_dict
def client_df2(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Car], details=server_name) send_q.put(df.details) #print ("Client at start:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C1 #print ("Waiting for C1") server_ready.wait() server_ready.clear() #print ("Client after waiting for server first time.:", df.versioned_heap.version_graph.nodes.keys()) # Pull from the server. df.pull() #print ("Client after first pull:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() cars = df.read_all(Car) assert (2 == len(cars)) c1, c2 = cars #print ("Setting S1") # Setting point S1 client_ready.set() c2.yvel = 1 df.commit() #print ("Client after first modification:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C2 #print ("Waiting for C2") server_ready.wait() server_ready.clear() #print ("Client after waiting for server:", df.versioned_heap.version_graph.nodes.keys()) df.push() #print ("Client after pushing:", df.versioned_heap.version_graph.nodes.keys()) # Setting point S2 #print ("Setting S2") client_ready.set() # Waiting at point c3 #print ("Waiting for C3") server_ready.wait() server_ready.clear() df.pull() #print ("Client after pulling second time:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() c1 = df.read_one(Car, 0) c2 = df.read_one(Car, 1) assert ("xvel" not in c1.__dict__) assert ("yvel" not in c1.__dict__) assert ("xpos" not in c1.__dict__) assert ("ypos" not in c1.__dict__) assert ("oid" not in c1.__dict__) assert (c1.xvel is 1) assert (c1.yvel is 1) assert (c1.xpos is 0) assert (c1.ypos is 0) assert (c1.oid is 0) assert ("xvel" not in c2.__dict__) assert ("yvel" not in c2.__dict__) assert ("xpos" not in c2.__dict__) assert ("ypos" not in c2.__dict__) assert ("oid" not in c2.__dict__) assert (c2.xvel is 0) assert (c2.yvel is 1) assert (c2.xpos is 0) assert (c2.ypos is 0) assert (c2.oid is 1) # Setting point S3 #print ("Setting S3") client_ready.set()
def client_df1(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Car], details=server_name) send_q.put(df.details) # Waiting at point C1 server_ready.wait() server_ready.clear() # Pull from the server. df.pull() df.checkout() cars = df.read_all(Car) assert (1 == len(cars)) c = cars[0] assert ("xvel" not in c.__dict__) assert ("yvel" not in c.__dict__) assert ("xpos" not in c.__dict__) assert ("ypos" not in c.__dict__) assert ("oid" not in c.__dict__) assert (c.xvel is 1) assert (c.yvel is 0) assert (c.xpos is 0) assert (c.ypos is 0) assert (c.oid is 0) df.commit() # Setting point S1 client_ready.set() # Waiting at point C2 server_ready.wait() server_ready.clear() df.pull() df.checkout() cars = df.read_all(Car) assert (1 == len(cars)) c = cars[0] assert ("xvel" not in c.__dict__) assert ("yvel" not in c.__dict__) assert ("xpos" not in c.__dict__) assert ("ypos" not in c.__dict__) assert ("oid" not in c.__dict__) assert (c.xvel is 1) assert (c.yvel is 1) assert (c.xpos is 0) assert (c.ypos is 0) assert (c.oid is 0) df.commit() df.checkout() c.xpos = 1 c.ypos = 1 c2 = Car(1) df.add_one(Car, c2) df.commit() df.push() # Setting point S2 client_ready.set() # Waiting at point C3 server_ready.wait() server_ready.clear() df.pull() df.checkout() assert (df.read_one(Car, 1) is None) assert (df.read_one(Car, 2) is None) # This does not work yet. Have to figure it out. # limitation of making it a framework rather than # a programming language itself. # Cannot invalidate old references without holding the # reference itself. #assert ("xvel" not in c2.__dict__) #assert ("yvel" not in c2.__dict__) #assert ("xpos" not in c2.__dict__) #assert ("ypos" not in c2.__dict__) #assert ("oid" not in c2.__dict__) #assert (c2.xvel is 0) #assert (c2.yvel is 0) #assert (c2.xpos is 0) #assert (c2.ypos is 0) #assert (c2.oid is 1) #assert (c2.__r_df__ is None) #assert (Car.__r_table__.object_table[1] == { # "oid": {"type": Datatype.INTEGER, "value": 0}, # "xvel": {"type": Datatype.INTEGER, "value": 0}, # "yvel": {"type": Datatype.INTEGER, "value": 0}, # "xpos": {"type": Datatype.INTEGER, "value": 0}, # "ypos": {"type": Datatype.INTEGER, "value": 0} # }) # Setting point S3 client_ready.set()
def client_df5(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Car], details=server_name) send_q.put(df.details) # Waiting at point C1 server_ready.wait() server_ready.clear() # Pull from the server. df.pull() df.checkout() cars = df.read_all(Car) assert (1 == len(cars)) c = cars[0] assert ("xvel" not in c.__dict__) assert ("yvel" not in c.__dict__) assert ("xpos" not in c.__dict__) assert ("ypos" not in c.__dict__) assert ("oid" not in c.__dict__) assert (c.xvel is 1) assert (c.yvel is 0) assert (c.xpos is 0) assert (c.ypos is 0) assert (c.oid is 0) df.commit() # Setting point S1 client_ready.set() # Waiting at point C2 server_ready.wait() server_ready.clear() df.pull() df.checkout() cars = df.read_all(Car) assert (1 == len(cars)) c = cars[0] assert ("xvel" not in c.__dict__) assert ("yvel" not in c.__dict__) assert ("xpos" not in c.__dict__) assert ("ypos" not in c.__dict__) assert ("oid" not in c.__dict__) assert (c.xvel is 1) assert (c.yvel is 1) assert (c.xpos is 0) assert (c.ypos is 0) assert (c.oid is 0) df.commit() df.checkout() c.xpos = 1 c.ypos = 1 c2 = Car(1) df.add_one(Car, c2) df.commit() df.push() # Setting point S2 client_ready.set() # Waiting at point C3 server_ready.wait() server_ready.clear() df.pull() df.checkout() assert (df.read_one(Car, 1) is None) assert (df.read_one(Car, 2) is None) # Setting point S3 client_ready.set()
def client_df5(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Car], details=server_name) send_q.put(df.details) # Waiting at point C1 server_ready.wait() server_ready.clear() # Pull from the server. df.pull() df.checkout() cars = df.read_all(Car) assert (1 == len(cars)) c = cars[0] assert ("xvel" not in c.__dict__) assert ("yvel" not in c.__dict__) assert ("xpos" not in c.__dict__) assert ("ypos" not in c.__dict__) assert ("oid" not in c.__dict__) assert (c.xvel is 1) assert (c.yvel is 0) assert (c.xpos is 0) assert (c.ypos is 0) assert (c.oid is 0) df.commit() # Setting point S1 client_ready.set() # Waiting at point C2 server_ready.wait() server_ready.clear() df.pull() df.checkout() cars = df.read_all(Car) assert (1 == len(cars)) c = cars[0] assert ("xvel" not in c.__dict__) assert ("yvel" not in c.__dict__) assert ("xpos" not in c.__dict__) assert ("ypos" not in c.__dict__) assert ("oid" not in c.__dict__) assert (c.xvel is 1) assert (c.yvel is 1) assert (c.xpos is 0) assert (c.ypos is 0) assert (c.oid is 0) df.commit() df.checkout() c.xpos = 1 c.ypos = 1 c2 = Car(1) df.add_one(Car, c2) df.commit() df.push() # Setting point S2 client_ready.set() # Waiting at point C3 server_ready.wait() server_ready.clear() df.pull() df.checkout() assert (df.read_one(Car, 1) is None) assert (df.read_one(Car, 2) is None) # Setting point S3 client_ready.set()
def client_df2(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Car], details=server_name) send_q.put(df.details) #print ("Client at start:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C1 #print ("Waiting for C1") server_ready.wait() server_ready.clear() #print ("Client after waiting for server first time.:", df.versioned_heap.version_graph.nodes.keys()) # Pull from the server. df.pull() #print ("Client after first pull:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() cars = df.read_all(Car) assert (2 == len(cars)) c1, c2 = cars #print ("Setting S1") # Setting point S1 client_ready.set() c2.yvel = 1 df.commit() #print ("Client after first modification:", df.versioned_heap.version_graph.nodes.keys()) # Waiting at point C2 #print ("Waiting for C2") server_ready.wait() server_ready.clear() #print ("Client after waiting for server:", df.versioned_heap.version_graph.nodes.keys()) df.push() #print ("Client after pushing:", df.versioned_heap.version_graph.nodes.keys()) # Setting point S2 #print ("Setting S2") client_ready.set() # Waiting at point c3 #print ("Waiting for C3") server_ready.wait() server_ready.clear() df.pull() #print ("Client after pulling second time:", df.versioned_heap.version_graph.nodes.keys()) df.checkout() c1 = df.read_one(Car, 0) c2 = df.read_one(Car, 1) assert ("xvel" not in c1.__dict__) assert ("yvel" not in c1.__dict__) assert ("xpos" not in c1.__dict__) assert ("ypos" not in c1.__dict__) assert ("oid" not in c1.__dict__) assert (c1.xvel is 1) assert (c1.yvel is 1) assert (c1.xpos is 0) assert (c1.ypos is 0) assert (c1.oid is 0) assert ("xvel" not in c2.__dict__) assert ("yvel" not in c2.__dict__) assert ("xpos" not in c2.__dict__) assert ("ypos" not in c2.__dict__) assert ("oid" not in c2.__dict__) assert (c2.xvel is 0) assert (c2.yvel is 1) assert (c2.xpos is 0) assert (c2.ypos is 0) assert (c2.oid is 1) # Setting point S3 #print ("Setting S3") client_ready.set()
def client_df1(send_q, recv_q, server_ready, client_ready): server_name = recv_q.get() df = Dataframe("CLIENT_TEST", [Car], details=server_name) send_q.put(df.details) # Waiting at point C1 server_ready.wait() server_ready.clear() # Pull from the server. df.pull() df.checkout() cars = df.read_all(Car) assert (1 == len(cars)) c = cars[0] assert ("xvel" not in c.__dict__) assert ("yvel" not in c.__dict__) assert ("xpos" not in c.__dict__) assert ("ypos" not in c.__dict__) assert ("oid" not in c.__dict__) assert (c.xvel is 1) assert (c.yvel is 0) assert (c.xpos is 0) assert (c.ypos is 0) assert (c.oid is 0) df.commit() # Setting point S1 client_ready.set() # Waiting at point C2 server_ready.wait() server_ready.clear() df.pull() df.checkout() cars = df.read_all(Car) assert (1 == len(cars)) c = cars[0] assert ("xvel" not in c.__dict__) assert ("yvel" not in c.__dict__) assert ("xpos" not in c.__dict__) assert ("ypos" not in c.__dict__) assert ("oid" not in c.__dict__) assert (c.xvel is 1) assert (c.yvel is 1) assert (c.xpos is 0) assert (c.ypos is 0) assert (c.oid is 0) df.commit() df.checkout() c.xpos = 1 c.ypos = 1 c2 = Car(1) df.add_one(Car, c2) df.commit() df.push() # Setting point S2 client_ready.set() # Waiting at point C3 server_ready.wait() server_ready.clear() df.pull() df.checkout() assert (df.read_one(Car, 1) is None) assert (df.read_one(Car, 2) is None) # This does not work yet. Have to figure it out. # limitation of making it a framework rather than # a programming language itself. # Cannot invalidate old references without holding the # reference itself. #assert ("xvel" not in c2.__dict__) #assert ("yvel" not in c2.__dict__) #assert ("xpos" not in c2.__dict__) #assert ("ypos" not in c2.__dict__) #assert ("oid" not in c2.__dict__) #assert (c2.xvel is 0) #assert (c2.yvel is 0) #assert (c2.xpos is 0) #assert (c2.ypos is 0) #assert (c2.oid is 1) #assert (c2.__r_df__ is None) #assert (Car.__r_table__.object_table[1] == { # "oid": {"type": Datatype.INTEGER, "value": 0}, # "xvel": {"type": Datatype.INTEGER, "value": 0}, # "yvel": {"type": Datatype.INTEGER, "value": 0}, # "xpos": {"type": Datatype.INTEGER, "value": 0}, # "ypos": {"type": Datatype.INTEGER, "value": 0} # }) # Setting point S3 client_ready.set()