Your message dated Thu, 29 Jan 2015 23:33:35 +0000
with message-id <[email protected]>
and subject line Bug#772543: fixed in python-psutil 2.2.0-1
has caused the Debian Bug report #772543,
regarding python-psutil: severak filehandle leaks
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
772543: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=772543
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: python-psutil
Version: 2.1.1-1+b1
Severity: important
Tags: patch


When using psutil to query system statistics, several function leak a file
handle by returning without closing the file handle.

When this is used on a regular basis, the system will fail with too many open
file handles:

eg.

def per_cpu_times():
    """Return a list of namedtuple representing the CPU times
    for every CPU available on the system.
    """
    cpus = []
    f = open('/proc/stat', 'rb')
    try:
        # get rid of the first line which refers to system wide CPU stats
        f.readline()
        CPU = b('cpu')
        for line in f:
            if line.startswith(CPU):
                values = line.split()
                fields = values[1:len(scputimes._fields) + 1]
                fields = [float(x) / CLOCK_TICKS for x in fields]
                entry = scputimes(*fields)
                cpus.append(entry)
        return cpus
    finally:
        f.close()



-- System Information:
Debian Release: 8.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.17-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages python-psutil depends on:
ii  libc6       2.19-13
ii  python      2.7.8-2
pn  python:any  <none>

python-psutil recommends no packages.

python-psutil suggests no packages.

-- no debconf information
This message is subject to the following terms and conditions: MAIL 
DISCLAIMER<http://www.barco.com/en/maildisclaimer>
Description: pslinux leaks several filehandles by returning prematurely
 This patch closes the filehandles before returning. An alternative way
 of handling this more cleanly, but a bit larger rewrite, would be to
 use use a with statement. This would be more clean.
 .
 python-psutil (2.1.1-1+barco2) unstable; urgency=low
 .
   * patch for misc filehandle leaks in pslinux
Author: Marc Leeman <[email protected]>

--- python-psutil-2.1.1.orig/psutil/_pslinux.py
+++ python-psutil-2.1.1/psutil/_pslinux.py
@@ -248,6 +248,7 @@ def per_cpu_times():
                 fields = [float(x) / CLOCK_TICKS for x in fields]
                 entry = scputimes(*fields)
                 cpus.append(entry)
+	f.close()
         return cpus
     finally:
         f.close()
@@ -339,6 +340,7 @@ def boot_time():
             if line.startswith(BTIME):
                 ret = float(line.strip().split()[1])
                 BOOT_TIME = ret
+		f.close()
                 return ret
         raise RuntimeError("line 'btime' not found")
     finally:
@@ -768,7 +770,9 @@ class Process(object):
             f = open(fname, "rt")
         try:
             # return the args as a list
-            return [x for x in f.read().split('\x00') if x]
+	    r = [x for x in f.read().split('\x00') if x]
+	    f.close()
+            return r
         finally:
             f.close()
 
@@ -862,6 +866,7 @@ class Process(object):
         f = open("/proc/%s/statm" % self.pid, 'rb')
         try:
             vms, rss = f.readline().split()[:2]
+	    f.close()
             return _common.pmem(int(rss) * PAGESIZE,
                                 int(vms) * PAGESIZE)
         finally:
@@ -990,6 +995,7 @@ class Process(object):
                 elif line.startswith(NON_VOLUNTARY):
                     unvol = int(line.split()[1])
                 if vol is not None and unvol is not None:
+		    f.close()
                     return _common.pctxsw(vol, unvol)
             raise NotImplementedError(
                 "'voluntary_ctxt_switches' and 'nonvoluntary_ctxt_switches'"
@@ -1005,6 +1011,7 @@ class Process(object):
             THREADS = b("Threads:")
             for line in f:
                 if line.startswith(THREADS):
+		    f.close()
                     return int(line.split()[1])
             raise NotImplementedError("line not found")
         finally:
@@ -1140,7 +1147,9 @@ class Process(object):
                         letter = letter.decode()
                     # XXX is '?' legit? (we're not supposed to return
                     # it anyway)
-                    return PROC_STATUSES.get(letter, '?')
+		    r  = PROC_STATUSES.get(letter, '?')
+		    f.close()
+		    return r
         finally:
             f.close()
 
@@ -1193,6 +1202,7 @@ class Process(object):
             for line in f:
                 if line.startswith(PPID):
                     # PPid: nnnn
+		    f.close()
                     return int(line.split()[1])
             raise NotImplementedError("line not found")
         finally:
@@ -1206,7 +1216,9 @@ class Process(object):
             for line in f:
                 if line.startswith(UID):
                     _, real, effective, saved, fs = line.split()
-                    return _common.puids(int(real), int(effective), int(saved))
+		    r = _common.puids(int(real), int(effective), int(saved))
+		    f.close()
+		    return r
             raise NotImplementedError("line not found")
         finally:
             f.close()
@@ -1219,7 +1231,9 @@ class Process(object):
             for line in f:
                 if line.startswith(GID):
                     _, real, effective, saved, fs = line.split()
-                    return _common.pgids(int(real), int(effective), int(saved))
+		    r = _common.pgids(int(real), int(effective), int(saved))
+		    f.close()
+		    return r
             raise NotImplementedError("line not found")
         finally:
             f.close()

--- End Message ---
--- Begin Message ---
Source: python-psutil
Source-Version: 2.2.0-1

We believe that the bug you reported is fixed in the latest version of
python-psutil, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Sandro Tosi <[email protected]> (supplier of updated python-psutil package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Thu, 29 Jan 2015 23:25:58 +0000
Source: python-psutil
Binary: python-psutil python3-psutil
Architecture: source amd64
Version: 2.2.0-1
Distribution: experimental
Urgency: medium
Maintainer: Sandro Tosi <[email protected]>
Changed-By: Sandro Tosi <[email protected]>
Description:
 python-psutil - module providing convenience functions for managing processes
 python3-psutil - module providing convenience functions for managing processes 
(Py
Closes: 772543
Changes:
 python-psutil (2.2.0-1) experimental; urgency=medium
 .
   * New upstream release
     - fix file descriptors leakage; thanks to Marc Leeman; Closes: #772543
   * debian/control
     - update Homepage to github
     - bump Standards-Version to 3.9.6 (no changes needed)
   * debian/rules
     - update upstream changelog
     - install README.rst file in doc too
Checksums-Sha1:
 e30f37c494de82fe4bea591f09902dd91fdb155e 2160 python-psutil_2.2.0-1.dsc
 bc4d6d7641afa2f9619121da5194cba83098341a 223676 python-psutil_2.2.0.orig.tar.gz
 037fec6ce12422a2db78ce2f70abb4f7c497ec43 4588 
python-psutil_2.2.0-1.debian.tar.xz
 a0b15e018006b3ad562bcffddcfd2b3da0e85564 122584 python-psutil_2.2.0-1_amd64.deb
 482cbd40dbd620ed799e76e87b80295718eb7ce7 60378 python3-psutil_2.2.0-1_amd64.deb
Checksums-Sha256:
 9d3c25e75198b4a0c9ac0545c910c1c86e949b5681d0f828cec410f4a9228850 2160 
python-psutil_2.2.0-1.dsc
 b15cc9e7cad0991bd1cb806fa90ea85ba3a95d0f1226625ecef993294ad61521 223676 
python-psutil_2.2.0.orig.tar.gz
 e7661b05c695dd3611582cdb4241ceb9fc56e45a90a8b84910c30147757f5c54 4588 
python-psutil_2.2.0-1.debian.tar.xz
 47a1d3d8c3f855a8538e17cb0fd1a8b124cf52532090af8839490506f1e9fbe2 122584 
python-psutil_2.2.0-1_amd64.deb
 a7a9cd4d2c54d67684a75b8a8b2ccbf663cb5638cbe80109d6e8477375ca180d 60378 
python3-psutil_2.2.0-1_amd64.deb
Files:
 2239ebc94d9dc427bd52cd6d373fe5e6 2160 python optional python-psutil_2.2.0-1.dsc
 b8f5ce3c47edc5e4491ef05a61387116 223676 python optional 
python-psutil_2.2.0.orig.tar.gz
 b5cdc608d189c1b256eb18315b3ab748 4588 python optional 
python-psutil_2.2.0-1.debian.tar.xz
 13a9ed36d3bdef97225cb9db09f82809 122584 python optional 
python-psutil_2.2.0-1_amd64.deb
 1df0cba62dd428c0a02ebb4ca52c14d0 60378 python optional 
python3-psutil_2.2.0-1_amd64.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJUysIfAAoJEP6NePn+T04Q5pYP/jz/F2KUKYssm3t/ACJRpQ/6
qDtLmT72XO78j1YF8BIOUUX+Y72oOHYNRYa/1ZG/6dy0klmtdtMUG4YR5fIOtrT0
TVjVKfTuIynxp+ULYJx1H0wwXEn5G5WUFW7dysQ+oHKHxuj9TNfyz5Tk2vK0lPGL
idLV1R/QSE877OU74xYwNNk6mcPno0R7mnOSCr0SSktyma2q5V67PIRosVxCB61c
xBgRppW+RKx2xGIzR84NVUzqGxAfjqxgcApm9NK1mGUkc4/UFf2hP5NPD28WNDKW
EpJuJxV6C/ziUwql7xjoRJv8H+IWPIjZCzwoabiTlEBK/TGw3ZDtTOEOXxEqwb7w
hZ8Fnn7AScnUST/UQArFd1MzGjm8X8SpbRPdRA7d+SzkCIeEjqn2IUxWZ2tqEVtu
8x95hvPVCmInaA3mvkU4ocvytSnNd308yk209COpLn+j3tNUj/vqG6OSgbLi9pD6
bF1TvcSG04+uA5OGeDcAIKsxscRcJZwPqo6C83FzHYcJm1UD6vZkA7cb6VYzY+Ns
MIbQzI8R+32X8OvGlYGTFCHtFwGFtWA5Oslp4vMBnK7QShSZQYu6+ldbxi4xSLvI
jASfxyQzDI/6bJQ5wMmylW3D+zR+mRiFfbL6qNQR7ZEXx02IuRxzarvn7AUUYO7+
GTgm3q3avXNK0wStp7nr
=bSWr
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to