From patchwork Wed Feb 25 21:17:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Erdmann?= X-Patchwork-Id: 443660 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 8C79C140082 for ; Thu, 26 Feb 2015 08:23:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=mailerd.de header.i=@mailerd.de header.b=cwHdU/fw; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C4309A342A; Wed, 25 Feb 2015 21:23:33 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g3No4hEBdb5P; Wed, 25 Feb 2015 21:23:32 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 91C5EA3406; Wed, 25 Feb 2015 21:23:32 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 250B01C2214 for ; Wed, 25 Feb 2015 21:23:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 1FB5632E44 for ; Wed, 25 Feb 2015 21:23:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nuv8n3FAaoDS for ; Wed, 25 Feb 2015 21:23:30 +0000 (UTC) X-Greylist: delayed 00:05:47 by SQLgrey-1.7.6 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by silver.osuosl.org (Postfix) with ESMTPS id 3A635252F2 for ; Wed, 25 Feb 2015 21:23:30 +0000 (UTC) Received: by mail-wi0-f181.google.com with SMTP id r20so8260733wiv.2 for ; Wed, 25 Feb 2015 13:23:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerd.de; s=mails; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=YlVf5ZF05d20trOTbLDmCIBIbeHU7PGHrRRjqnVJUME=; b=cwHdU/fw4OAxluMWm3zqFuEkEX1YsMJGkNSjqXxLQhETE0vDsXzzWieXsUJGoKDq+7 ptjQgkvglQI542F8ZihabolM+IlUTSDYXbFlm2fNedWlvq7G1iC+qlNTWbHM42dtBdj2 6oRlXqG+2YK8jFYNzxhmoSJ/qzdGn0v39uZ3s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; bh=YlVf5ZF05d20trOTbLDmCIBIbeHU7PGHrRRjqnVJUME=; b=fx3kU2FioNtoFFTahRsjuGxRJzC+QDS8TD0sYgL3ls1jzn9Gy12cj61GTc8trWLPDU 8dujkYQzNujq0tSVU+bsfTFogaYcNptV7ES1U9WDU9ZqAt7xXjmHaW6/PXxkFsYAOWMc O5YLS9dy1LXu+N/tFtNQWwZopeh4Q9temYUzMUHUU3ygCxhkd8RgPhmqho1mOqPR7hHu yLspKnVoicj8vtvSDKTVpoB0M5Y5T3O/V3yXNVd5W2DqioLhxtVWZQSNhidG7z3opNRv SEZ5ZTmgDSpuirJxTaFT7y4EuGZutNmVDdkJJZh912BCuNYfS5Xol+ISs+9b8LzlvR+j ZGXw== X-Gm-Message-State: ALoCoQkUwFsZbYhFwU3puH37evSUBa9I2HuOXE9CVR9kJNVfVPaxWrWPNAUUuJEUS+dpH9fYEQSu X-Received: by 10.194.63.230 with SMTP id j6mr9803279wjs.31.1424899072667; Wed, 25 Feb 2015 13:17:52 -0800 (PST) Received: from localhost.localdomain (dslb-188-105-009-107.188.105.pools.vodafone-ip.de. [188.105.9.107]) by mx.google.com with ESMTPSA id fo9sm26800926wib.16.2015.02.25.13.17.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 13:17:51 -0800 (PST) From: =?UTF-8?q?Andr=C3=A9=20Erdmann?= To: buildroot@buildroot.org Date: Wed, 25 Feb 2015 22:17:23 +0100 Message-Id: <1424899050-24932-7-git-send-email-dywi@mailerd.de> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1424899050-24932-1-git-send-email-dywi@mailerd.de> References: <1424899050-24932-1-git-send-email-dywi@mailerd.de> MIME-Version: 1.0 Cc: thomas.petazzoni@free-electrons.com Subject: [Buildroot] [PATCH 06/13] autobuild-run: explicitly close web file handles X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Close urlopen() file handles as soon as possible rather than waiting until their refcount drops to zero. Signed-off-by: André Erdmann --- scripts/autobuild-run | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/autobuild-run b/scripts/autobuild-run index 5db21b1..fee68b7 100755 --- a/scripts/autobuild-run +++ b/scripts/autobuild-run @@ -59,6 +59,7 @@ from __future__ import print_function +import contextlib import csv from random import randint import subprocess @@ -79,6 +80,7 @@ else: import urllib2 as _urllib urlopen = _urllib.urlopen +urlopen_closing = lambda uri: contextlib.closing(urlopen(uri)) if sys.hexversion >= 0x3000000: def decode_bytes(b): @@ -101,8 +103,8 @@ def log_write(logf, msg): logf.flush() def check_version(): - r = urlopen('http://autobuild.buildroot.org/version') - version = int(decode_bytes(r.readline()).strip()) + with urlopen_closing('http://autobuild.buildroot.org/version') as r: + version = int(decode_bytes(r.readline()).strip()) if version > VERSION: print("ERROR: script version too old, please upgrade.") sys.exit(1) @@ -155,9 +157,10 @@ def get_toolchain_configs(): - hostarch: the host architecture for which the toolchain is built - contents: an array of lines of the defconfig """ + tc_cfg_uri = 'http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv' - r = urlopen('http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv') - l = decode_byte_list(r.readlines()) + with urlopen_closing(tc_cfg_uri) as r: + l = decode_byte_list(r.readlines()) configs = [] for row in csv.reader(l): config = {} @@ -171,8 +174,8 @@ def get_toolchain_configs(): if hostarch != config["hostarch"]: continue config["libc"] = row[2] - r = urlopen(config["url"]) - config["contents"] = decode_byte_list(r.readlines()) + with urlopen_closing(config["url"]) as r: + config["contents"] = decode_byte_list(r.readlines()) configs.append(config) return configs