def shutdown_servers(scenario): for world_attr in dir(world): if not world_attr.startswith('_'): obj = world.__getattribute__(world_attr) if isinstance(obj, Server): obj.go_down()
def save_world(self, filepath): with open(filepath, 'w') as f: for var in dir(world): if not var.startswith('_') and var not in ('absorb', 'spew'): pickle.dump((var, world.__getattribute__(var)), f)