[Zope-dev] Threads, ZODB, deactivate, setstate, etc...

Olivier Deckmyn odeckmyn.list@teaser.fr
Thu, 9 Aug 2001 09:18:46 +0200


There's nobody who can answer this question ? At least give me an URL that
explain _p_deactivate, etc...

Please !

Olivier

> -----Message d'origine-----
> De : zope-dev-admin@zope.org [mailto:zope-dev-admin@zope.org]De la part
> de Olivier Deckmyn
> Envoyé : mercredi 8 août 2001 10:48
> À : zope-dev@zope.org
> Objet : [Zope-dev] Threads, ZODB, deactivate, setstate, etc...
>
>
> Hi there !
>
> I am working on my product ZExternalNews
> (http://www.zope.org/Members/odeckmyn/ZExternalNews).
> I have a problem that I did not have anticipated !
>
> My product is made of 3 classes:
>
> 1/ ZExternalNewsManager (usually one per site), folderish that contains
> several ZExternalNewsChannel
> 2/ ZExternalNewsChannel (several per Manager), itemish. Contains 2
> persistent properties (title and url) and a _v_items, a list of
> ZExternalNewsItem
> 3/ ZExternalNewsItem a very simple Python class (no inheritance from zope
> nor ZODB). It handles an atomic news item (like a single news item in
> slashdot for example).
>
> When ZExternalNewsManager starts, I also "fork" a thread that (simplified)
> does :
>
> while 1:
>     MyManager.Refresh()
>     sleep(MyManager.delay)
>
> Where MyManager.Refresh is a loop that calls refresh on every channel.
>
> This would work in a wonderful land...but not in real life. I've been
> searching for hours now...
> My problem is :
>
>
> It works for some time (sometime 10sec, sometimes 2 hours, sometime 10
> min...), and then, I got a lot of :
>
>
> 2001-08-07T17:36:04 ERROR(200) ZODB Couldn't load state for
> '\000\000\000\000\000\000WG'
> Traceback (innermost last):
>   File /isp/zope/newfun/lib/python/ZODB/Connection.py, line 508,
> in setstate
> AttributeError: 'None' object has no attribute 'load'
>
> (a lot of = one per ZExternalChannel instance)
>
> and a last :
>
> Exception in thread Thread-4:
> Traceback (innermost last):
>   File "/usr/local/lib/python1.5/threading.py", line 376, in __bootstrap
>     self.run()
>   File
> "/isp/zope/newfun/lib/python/Products/ZExternalNews/ZExternalNews.
> py", line
> 454, in run
>     self._manager.Refresh()
>   File "/isp/zope/newfun/lib/python/ZODB/Connection.py", line 508, in
> setstate
>     p, serial = self._storage.load(oid, self._version)
> AttributeError: 'None' object has no attribute 'load'
>
> After hours of thinking, I think this is because ZODB ask my objects to go
> to sleep (is this DEACTIVATING ?).
>
> The last modification I made was to implement __setstate__ so that _v_*
> attributes are declared there : I thought it would be ok after that. It is
> not :(
>
>
> Please help me ! It is quite a frustrating experience ! Do not hesitate to
> Is there a document I should read before understanding ? I think I've read
> quite a lot of things until now ! ;)
>
> Attached is the latest version of the .py. Other part of the product is
> downloadable here : http://www.zope.org/Members/odeckmyn/ZExternalNews
>
> Thanx for your support.
>
> Olivier.
>
>
>