nodes: 0, module; 1, function_definition; 2, function_name:get_clusters; 3, parameters; 4, block; 5, identifier:self; 6, identifier:platform; 7, identifier:retry_contexts; 8, identifier:all_clusters; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, while_statement; 13, expression_statement; 14, expression_statement; 15, return_statement; 16, string; 17, assignment; 18, assignment; 19, boolean_operator; 20, block; 21, assignment; 22, assignment; 23, identifier:ret; 24, string_content:return clusters sorted by load.; 25, identifier:possible_cluster_info; 26, dictionary; 27, identifier:candidates; 28, call; 29, identifier:candidates; 30, not_operator; 31, expression_statement; 32, for_statement; 33, expression_statement; 34, identifier:ret; 35, call; 36, identifier:ret; 37, call; 38, identifier:set; 39, argument_list; 40, identifier:possible_cluster_info; 41, call; 42, identifier:cluster; 43, call; 44, block; 45, augmented_assignment; 46, identifier:sorted; 47, argument_list; 48, identifier:sorted; 49, argument_list; 50, call; 51, identifier:wait_for_any_cluster; 52, argument_list; 53, identifier:sorted; 54, argument_list; 55, expression_statement; 56, if_statement; 57, if_statement; 58, try_statement; 59, identifier:candidates; 60, call; 61, call; 62, keyword_argument; 63, identifier:ret; 64, keyword_argument; 65, attribute; 66, argument_list; 67, identifier:retry_contexts; 68, identifier:candidates; 69, keyword_argument; 70, assignment; 71, attribute; 72, block; 73, attribute; 74, block; 75, block; 76, except_clause; 77, identifier:set; 78, argument_list; 79, attribute; 80, argument_list; 81, identifier:key; 82, lambda; 83, identifier:key; 84, lambda; 85, identifier:copy; 86, identifier:copy; 87, identifier:all_clusters; 88, identifier:key; 89, call; 90, identifier:ctx; 91, subscript; 92, identifier:ctx; 93, identifier:in_retry_wait; 94, continue_statement; 95, identifier:ctx; 96, identifier:failed; 97, continue_statement; 98, expression_statement; 99, expression_statement; 100, identifier:OsbsException; 101, block; 102, list_comprehension; 103, identifier:possible_cluster_info; 104, identifier:values; 105, lambda_parameters; 106, attribute; 107, lambda_parameters; 108, attribute; 109, identifier:attrgetter; 110, argument_list; 111, identifier:retry_contexts; 112, attribute; 113, assignment; 114, assignment; 115, expression_statement; 116, identifier:c; 117, for_in_clause; 118, if_clause; 119, identifier:c; 120, attribute; 121, identifier:priority; 122, identifier:c; 123, identifier:c; 124, identifier:load; 125, string; 126, identifier:cluster; 127, identifier:name; 128, identifier:cluster_info; 129, call; 130, subscript; 131, identifier:cluster_info; 132, call; 133, identifier:c; 134, identifier:candidates; 135, attribute; 136, identifier:c; 137, identifier:cluster; 138, string_content:priority; 139, attribute; 140, argument_list; 141, identifier:possible_cluster_info; 142, identifier:cluster; 143, attribute; 144, argument_list; 145, subscript; 146, identifier:failed; 147, identifier:self; 148, identifier:get_cluster_info; 149, identifier:cluster; 150, identifier:platform; 151, identifier:ctx; 152, identifier:try_again_later; 153, attribute; 154, identifier:retry_contexts; 155, attribute; 156, identifier:self; 157, identifier:find_cluster_retry_delay; 158, identifier:c; 159, identifier:name
code: def get_clusters(self, platform, retry_contexts, all_clusters):
          ''' return clusters sorted by load. '''
  
          possible_cluster_info = {}
          candidates = set(copy.copy(all_clusters))
          while candidates and not possible_cluster_info:
              wait_for_any_cluster(retry_contexts)
  
              for cluster in sorted(candidates, key=attrgetter('priority')):
                  ctx = retry_contexts[cluster.name]
                  if ctx.in_retry_wait:
                      continue
                  if ctx.failed:
                      continue
                  try:
                      cluster_info = self.get_cluster_info(cluster, platform)
                      possible_cluster_info[cluster] = cluster_info
                  except OsbsException:
                      ctx.try_again_later(self.find_cluster_retry_delay)
              candidates -= set([c for c in candidates if retry_contexts[c.name].failed])
  
          ret = sorted(possible_cluster_info.values(), key=lambda c: c.cluster.priority)
          ret = sorted(ret, key=lambda c: c.load)
          return ret