def test(): import gettext _ = gettext.gettext formatter = logging.Formatter( '[%(asctime)s] [%(module)s] %(levelname)s: %(message)s', "%Y-%m-%d %H:%M:%S") logger = logging.getLogger() logger.setLevel(logging.DEBUG) stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.DEBUG) stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) import gc import pprint import cnchi.pacman.pac as pac try: pacman = pac.Pac( conf_path="/etc/pacman.conf", callback_queue=None) for index in range(1, 10000): print("Creating metalink...") meta4 = create( alpm=pacman, package_name="gnome", pacman_conf_file="/etc/pacman.conf") print(get_info(meta4)) meta4 = None objects = gc.collect() print("Unreachable objects: ", objects) print("Remaining garbage: ", pprint.pprint(gc.garbage)) pacman.release() del pacman except Exception as ex: template = "Can't initialize pyalpm. An exception of type {0} occured. Arguments:\n{1!r}" message = template.format(type(ex).__name__, ex.args) logging.error(message)
formatter = logging.Formatter( '[%(asctime)s] [%(module)s] %(levelname)s: %(message)s', "%Y-%m-%d %H:%M:%S") logger = logging.getLogger() logger.setLevel(logging.DEBUG) stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.DEBUG) stream_handler.setFormatter(formatter) logger.addHandler(stream_handler) import gc import pprint import cnchi.pacman.pac as pac try: pacman = pac.Pac(conf_path="/etc/pacman.conf", callback_queue=None) for i in range(1, 10000): print("Creating metalink...") meta4 = create(alpm=pacman, package_name="gnome", pacman_conf_file="/etc/pacman.conf") print(get_info(meta4)) meta4 = None n = gc.collect() print("Unreachable objects: ", n) print("Remaining garbage: ", pprint.pprint(gc.garbage)) pacman.release() del pacman