[MMTK] shelve problem

konrad.hinsen at laposte.net konrad.hinsen at laposte.net
Fri Dec 17 11:35:47 CET 2004

On Dec 16, 2004, at 23:44, Jaroslaw Kalinowski wrote:

>   File "/usr/lib/python2.3/site-packages/MMTK/Database.py", line 385, 
> in __getattr__
>     return getattr(self.type, attr)
> RuntimeError: maximum recursion depth exceeded
> What may be the source of the problem?
The shelve module uses the Python pickle module. MMTK.save uses 
Python's pickle code with the extensions from Numerical Python plus its 
own, which takes care of the singleton nature of database entries. 
Without that latter extension, you get the error message you quoted.

The Numeric-specific stuff has been integrated into the pickle module 
using the copy_reg module (which wasn't around when the initial MMTK 
code was written), so that could be handled in a cleaner way now. The 
drawback would be that existing pickled files containing array data 
(i.e. nearly everything) would no longer be readable. I am not aware of 
a solution to the singleton problem that would be compatible with the 
shelve module, but I haven't looked at that part of the Python library 
for a while - perhaps it has changed.

As a workaround, you can use the classes Pickler and Unpickler from 
MMTK.Utility to turn any MMTK object into a string, which you can then 
store in a shelve.

Konrad Hinsen
Laboratoire Léon Brillouin, CEA Saclay,
91191 Gif-sur-Yvette Cedex, France
Tel.: +33-1 69 08 79 25
Fax: +33-1 69 08 82 61
E-Mail: hinsen at llb.saclay.cea.fr

More information about the mmtk mailing list