Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def choose_host(service):
hosts = service.get_hosts()
if not hosts:
raise NoHostsAvailableException(service.service_name)
return random.choice(hosts)