luigimarmo / psutil

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

Named tuples in psutil._common not picklable #461

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Call psutil function that returns named tuple (e.g. psutil.disk_partitions())
2. Try to call pickle.dumps on returned value

What is the expected output?
Should return pickle serialized version of named tuple.

What do you see instead?
Throws pickle error. This is because the namedtuple variables are not named the 
same as the namedtuples themselves. For example:

nt_sysmeminfo = namedtuple('usage', 'total used free percent')

Pickle attempts to find the type that the namedtuple object is derived from via 
the psutil._common.usage variable, which does not exist (since it is instead 
located at psutil._common.nt_sysmeminfo). The problem can be corrected simply 
by changing the above line to:

nt_sysmeminfo = namedtuple('nt_sysmeminfo', 'total used free percent')

What version of psutil are you using? What Python version?
Python 2.7.6, psutil 1.2.1

On what operating system? Is it 32bit or 64bit version?
Debian Jessie, 64-bit

Please provide any additional information below.
See above ^^^

Original issue reported on code.google.com by countac...@gmail.com on 29 Dec 2013 at 7:26

GoogleCodeExporter commented 8 years ago
Thanks. I should have had a test for this.
Fixed in revision 49e78beda34c and others.

Original comment by g.rodola on 31 Dec 2013 at 10:51

GoogleCodeExporter commented 8 years ago
Closing out as fixed as 2.0.0 version is finally out.

Original comment by g.rodola on 10 Mar 2014 at 11:36