Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Tracker:
- def __init__(self):
- self.returned_host_names = set()
- self.host_type_so_far = set()
- def allocate(self, host_type):
- self.counter = 0
- self.host_type_so_far.add(host_type)
- if host_type in self.host_type_so_far:
- self.counter+=1
- while True:
- maybe_hostname = host_type + str(self.counter)
- if maybe_hostname not in self.returned_host_names:
- self.returned_host_names.add(maybe_hostname)
- print(self.returned_host_names)
- return maybe_hostname
- else:
- self.counter+=1
- def deallocate(self, hostname):
- if hostname in self.returned_host_names:
- self.returned_host_names.remove(hostname)
Add Comment
Please, Sign In to add comment