#!/usr/bin/python import libvirt from time import sleep from os import listdir from threading import Thread URLS = [ "qemu://skepp.knut.univention.de/system", "qemu://krus.knut.univention.de/system", "qemu://isalla.knut.univention.de/system", "qemu://boksel.knut.univention.de/system", "qemu://utby.knut.univention.de/system", ] def run(url): print url, try: c = libvirt.open(url) except libvirt.libvirtError as ex: print ex else: print def main(): libvirt.virEventRegisterDefaultImpl() while True: threads = [Thread(target=run, name=url, args=(url,)) for url in URLS] for thread in threads: thread.start() sleep(5) print listdir("/proc/self/fd") for thread in threads: thread.join(.1) sleep(5) if __name__ == '__main__': main()