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

Olivier Deckmyn odeckmyn.list@teaser.fr
Wed, 8 Aug 2001 10:47:30 +0200


C'est un message de format MIME en plusieurs parties.

------=_NextPart_000_0022_01C11FF7.86045AA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

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.



------=_NextPart_000_0022_01C11FF7.86045AA0
Content-Type: text/plain;
	name="ZExternalNews.py"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="ZExternalNews.py"

#########################################################################=
##########=0A=
## ZExternalNews.py =0A=
## (c)2001, Olivier DECKMYN=0A=
#########################################################################=
##########=0A=
=0A=
=0A=
"""This module purposes a thread-safe class to handle the management =
(load, =0A=
parse, browse, update etc...) of a syndicated news channel respecting =
RDF or =0A=
RSS format (XML based). =0A=
"""=0A=
=0A=
import os, time, string, sys=0A=
from threading import Lock, Thread=0A=
=0A=
try:=0A=
    from xml.sax import saxlib, saxexts=0A=
except:=0A=
    raise "ImportError", "PyXML is not installed. Install it from =
[Zope-dev] Help!!!(how to search for a file in a particular folder is there any method?)

	
  • Next message: [Zope-dev] Threads, ZODB, deactivate, setstate, etc...
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]