Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError 'Anonymous' on Debian squeeze #319

Closed
giampaolo opened this issue May 23, 2014 · 10 comments
Closed

KeyError 'Anonymous' on Debian squeeze #319

giampaolo opened this issue May 23, 2014 · 10 comments

Comments

@giampaolo
Copy link
Owner

From florent....@gmail.com on August 17, 2012 18:16:57

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: http://code.google.com/p/psutil/issues/detail?id=319

@giampaolo
Copy link
Owner Author

From florent....@gmail.com on August 17, 2012 09:30:38

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

@giampaolo
Copy link
Owner Author

From florent....@gmail.com on August 17, 2012 09:51:39

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)

@giampaolo
Copy link
Owner Author

From g.rodola on August 17, 2012 10:30:48

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

Status: FixedInSVN
Labels: OpSys-Linux Milestone-0.6.2

@giampaolo
Copy link
Owner Author

From florent....@gmail.com on August 17, 2012 10:48:14

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.

@giampaolo
Copy link
Owner Author

From g.rodola on August 17, 2012 10:49:43

Good. In the meantime I also fixed the RuntimeWarning.
Thanks.

@giampaolo
Copy link
Owner Author

From flt.john...@gmail.com on February 12, 2013 20:51:52

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
...

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 04:12:42

Updated csets after the SVN -> Mercurial migration: r1532 == revision 
dd0f202cad60

@giampaolo
Copy link
Owner Author

From g.rodola on April 07, 2013 18:21:49

Status: FixedInHG

@giampaolo
Copy link
Owner Author

From g.rodola on April 11, 2013 02:17:39

Labels: -Milestone-0.6.2 Milestone-0.7.0

@giampaolo
Copy link
Owner Author

From g.rodola on April 12, 2013 11:21:26

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant