This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lehmannro
Recipients georg.brandl, lehmannro
Date 2009-09-17.15:55:55
SpamBayes Score 2.5455893e-07
Marked as misclassified No
Message-id <1253202957.58.0.0745460877644.issue6932@psf.upfronthosting.co.za>
In-reply-to
Content
I'm reopening issue5483 by Zhigang Wang (zhigang) as a separate bug.

Shelves that are still open when Python terminates will try to sync. If
writeback=True, this pickles cached items.

In this example, serialization of Test() re-imports __main__, which is
already gc'd, and raises:
Exception cPickle.PicklingError: Can't pickle <class '__main__.Test'>:
it's not the same object as __main__.Test" in <bound method
Shelf.__del__ of {'a': <__main__.Test object at 0x...>}>

The error is ignored (due to Python already tearing down) but all cached
modifications are lost.
The promise "[t]he __del__() method of the Shelf class calls the close()
method, so the programmer generally need not do this explicitly" is not
true with writeback enabled.

I'm unsure if this error can be fixed (probably with atexit/weakref, but
that's more trouble than gain). I attached a patch to the docs simply
warning the user of this issue (+ documenting Shelf.close, + removing
above quote).
History
Date User Action Args
2009-09-17 15:55:57lehmannrosetrecipients: + lehmannro, georg.brandl
2009-09-17 15:55:57lehmannrosetmessageid: <1253202957.58.0.0745460877644.issue6932@psf.upfronthosting.co.za>
2009-09-17 15:55:56lehmannrolinkissue6932 messages
2009-09-17 15:55:55lehmannrocreate