shanecode / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

KeyError 'Anonymous' on Debian squeeze #319

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

this is happening with all versions including 0.6.1.

>>> import os, psutil
>>> p = psutil.Process(os.getpid())
>>> p.get_memory_maps()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./lib/python2.7/site-packages/psutil/__init__.py", line 570, in get_memory_maps
    for tupl in it:
  File "./lib/python2.7/site-packages/psutil/_pslinux.py", line 591, in get_memory_maps
    data['Anonymous:'],
KeyError: 'Anonymous:'

The hotfix I've applied is quite simple:
replace `data['Anonymous:']` with `data.get('Anonymous:', 0)`

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 6.0.5 (squeeze)
Release:        6.0.5
Codename:       squeeze

$ uname -a
Linux dmars 2.6.32-5-amd64 #1 SMP Sun May 6 04:00:17 UTC 2012 x86_64 GNU/Linux

Original issue reported on code.google.com by florent....@gmail.com on 17 Aug 2012 at 4:16

GoogleCodeExporter commented 9 years ago
Additional information

$ cat /proc/self/smaps
00400000-0040c000 r-xp 00000000 08:01 106569                             
/bin/cat
Size:                 48 kB
Rss:                  28 kB
Pss:                  28 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:        28 kB
Private_Dirty:         0 kB
Referenced:           28 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
0060c000-0060d000 rw-p 0000c000 08:01 106569                             
/bin/cat
Size:                  4 kB
Rss:                   4 kB
Pss:                   4 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         4 kB
Referenced:            4 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
0182b000-0184c000 rw-p 00000000 00:00 0                                  [heap]
Size:                132 kB
Rss:                  12 kB
Pss:                  12 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:        12 kB
Referenced:           12 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
7febe3628000-7febe3978000 r--p 00000000 08:01 98308                      
/usr/lib/locale/locale-archive
Size:               3392 kB
Rss:                  44 kB
Pss:                  19 kB
Shared_Clean:         40 kB
Shared_Dirty:          0 kB
Private_Clean:         4 kB
Private_Dirty:         0 kB
Referenced:           44 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
...

$ cat /proc/meminfo
MemTotal:         508668 kB
MemFree:          121656 kB
Buffers:            6640 kB
Cached:            91020 kB
SwapCached:        14892 kB
Active:           174396 kB
Inactive:         182156 kB
Active(anon):     153364 kB
Inactive(anon):   131204 kB
Active(file):      21032 kB
Inactive(file):    50952 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:        392184 kB
SwapFree:         280356 kB
Dirty:               480 kB
Writeback:             0 kB
AnonPages:        248424 kB
Mapped:            34476 kB
Shmem:             25676 kB
Slab:              18472 kB
SReclaimable:      10828 kB
SUnreclaim:         7644 kB
KernelStack:         832 kB
PageTables:         4684 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      646516 kB
Committed_AS:     498160 kB
VmallocTotal:   34359738367 kB
VmallocUsed:       20324 kB
VmallocChunk:   34359707636 kB
HardwareCorrupted:     0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:        8128 kB
DirectMap2M:      516096 kB

Original comment by florent....@gmail.com on 17 Aug 2012 at 4:30

GoogleCodeExporter commented 9 years ago
With the fix proposed in the initial message, the test suite seems to run fine.
Only 1 error reported.

$ python -m unittest discover -v psutil-read-only/test
...
======================================================================
ERROR: test_get_connections_unix (test_psutil.TestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/vagrant/pgdiff/psutil-read-only/test/test_psutil.py", line 206, in inner
    return fun(self, *args, **kwargs)
  File "/vagrant/pgdiff/psutil-read-only/test/test_psutil.py", line 1227, in test_get_connections_unix
    sock.bind(TESTFN)
  File "/srv/openerp/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 1] Operation not permitted

----------------------------------------------------------------------
Ran 223 tests in 24.418s

FAILED (errors=1)

Original comment by florent....@gmail.com on 17 Aug 2012 at 4:51

GoogleCodeExporter commented 9 years ago
Fixed in r1532, thanks.
Not sure about the other failure: I can't reproduce it on Ubuntu 12.04.

Original comment by g.rodola on 17 Aug 2012 at 5:30

GoogleCodeExporter commented 9 years ago
Thanks, it works.

----------------------------------------------------------------------
Ran 223 tests in 25.086s

OK

However, I have a RuntimeWarning because of a typo in test_psutil:
in "get_test_subprocess()" line 84, the comparison operator is wrong, should be 
`while time.time() < stop_at:`

The other error, "Operation not permitted", was because the current-workdir was 
on a shared drive in my VM. Once I moved it, the error is gone.

Original comment by florent....@gmail.com on 17 Aug 2012 at 5:48

GoogleCodeExporter commented 9 years ago
Good. In the meantime I also fixed the RuntimeWarning.
Thanks.

Original comment by g.rodola on 17 Aug 2012 at 5:49

GoogleCodeExporter commented 9 years ago
I'd like to mention that on my older machine I don't have Swap information in 
smaps so I've set that variable as data.get('Swap:',0) similarly.

Linux purplestar 2.6.24-32-generic #1 SMP Mon Dec 3 15:48:29 UTC 2012 i686 
GNU/Linux

08048000-080ef000 r-xp 00000000 08:03 35         /bin/bash
Size:                668 kB
Rss:                 572 kB
Shared_Clean:        568 kB
Shared_Dirty:          0 kB
Private_Clean:         4 kB
Private_Dirty:         0 kB
Referenced:          572 kB
080ef000-080f5000 rw-p 000a6000 08:03 35         /bin/bash
Size:                 24 kB
...

Original comment by flt.john...@gmail.com on 13 Feb 2013 at 4:51

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Updated csets after the SVN -> Mercurial migration:
r1532 == revision dd0f202cad60

Original comment by g.rodola on 2 Mar 2013 at 12:12

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 8 Apr 2013 at 1:21

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 11 Apr 2013 at 9:17

GoogleCodeExporter commented 9 years ago

Original comment by g.rodola on 12 Apr 2013 at 6:21