instead of try ... catch, you can do, "if uid in self.idle_peers" to check to see if uid is an item in the hashtable