Thanks for the pointer - I found the client_loop in ZEO.zrpc.connection
which starts on importing that module. A quick check with my bit of code
didn't see things working any better but I fear I may be completely
missing the point somewhere... I'll try again in the morning. Thanks
again for the pointer to the new version.
Matthew
Jim Fulton wrote:
Note that ZODB 3.7 already provides a separate dedicated client
asyncore loop. You might try using that. There is a beta release at:
http://download.zope.org/distribution/ZODB3-3.7.0b3.tar.gz
Note that this release should work well with easy_install or
zc.buildout. It doesn't include ZConfig, zdaemon, zope.interface,
zope.proxy, or zope.testing, as these are now handled as dependencies.
Also note that while the release is still beta, because I haven't had
time to make a final release, this release is being used in current
versions of Zope.
Jim
On Dec 7, 2006, at 12:44 PM, Matthew Pontefract wrote:
Hello
I'm writing client code that uses ZODB over a ZEO connection. In order
not to have to call connection.sync() to synchronise the cache with
the server I wish to provide the ZEO client with an asyncore mainloop
to which it can attach itself. No matter how I do this, however, my
clients
do not seem to be processing cache invalidation/update messages
asynchronously.
My client code does not make use of asyncore itself so the thread is
started especially for ZEO's use. I've tried starting the loop thread
*after* getting the ZEO connection:
==============================
class AsyncoreRunner(threading.Thread):
def __init__(self,env):
threading.Thread.__init__(self)
self.env=env
self.setDaemon(True)
def run(self):
self.env.sys.logger.info("Asyncore loop starting")
try:
asyncore.loop()
except Exception,ex:
self.env.sys.logger.error("Asyncore loop quitting:
%s"%str(ex))
self.env.sys.logger.info("Asycore loop ended")
addr = host, port
storage=ClientStorage.ClientStorage(addr)
db = DB(self.storage)
conn = self.db.open()
mt = AsyncoreRunner(self.env)
mt.start()
==============================
... and I've tried starting it BEFORE getting the connection
(providing a dummy dispatcher so that the asyncore.loop() does not
return immediately).
In either case, if I run two clients the following does not work where
I would imagine it should if the messages were being processed on the
asyncore thread.
CLIENT 1:
root = conn.root()
root['test']=10
transaction.commit()
CLIENT 2:
root['test']
... KeyError...
conn.sync()
root['test']
10
root['test'] = 20
transaction.commit()
CLIENT1:
root['test']
10 <----- Not 20!
conn.sync()
root['test']
20 <----- now it is!
Have I misunderstood things very badly? Am I approaching things too
simplistically?
I have googled and searched a lot of documentation but I just can't
find the key to my problem! Here's hoping that someone on this list
can help!
Many thanks in advance,
Matthew
_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/
ZODB-Dev mailing list - [email protected]
http://mail.zope.org/mailman/listinfo/zodb-dev
--
Jim Fulton mailto:[EMAIL PROTECTED] Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/
ZODB-Dev mailing list - [email protected]
http://mail.zope.org/mailman/listinfo/zodb-dev