RE: ZEO conflicts
"Boylan, Ross" <[email protected]>
| Newsgroups | gmane.comp.web.zope.zodb |
|---|---|
| Message-ID | <[email protected]> |
Thanks for clarifying how to use ZEO client with threads.
Given that the approach I used, though wasteful, should be harmless, why didn't it work?
On transaction.commit() I was just concerned it wasn't hooked up correctly if one used ZEO clients, and didn't see explicit statements or examples using it. Glad it's fine.
dbname is a string which is a path to a Unix domain socket. Concretely, I started the server with
runzeo -a ./zeotalk -f zeo.fs
and then my client has
dbname="./zeotalk"
and then, in each thread,
db = ZEO.DB(dbname)
conn = db.open()
__________________________________
From: [email protected] [[email protected]] on behalf of Jim Fulton [[email protected]]
Sent: Wednesday, October 12, 2016 5:30 AM
To: Boylan, Ross
Cc: zodb [[email protected]]
Subject: Re: [ZODB] ZEO conflicts
On Tue, Oct 11, 2016 at 4:13 PM, Boylan, Ross <[email protected]> wrote:
> With ZEO clients some of my transactions seem to get lost without causing any reported error report on the client, despite having 10 retries and a long and variable delay between retries. The clients are in separate threads, not separate processes, and I'm unclear exactly how this situation should be handled. Some of the docs say
> "Any number of processes can create a ClientStorage instance, and any number of threads in each process can be using that instance. ClientStorage aggressively caches objects locally, so in order to avoid using stale data the ZEO server sends an invalidation message to all the connected ClientStorage instances on every write operation." (http://www.zodb.org/en/latest/articles/old-guide/zeo.html). I tried to do almost everything within threads.
Create one client per process. Create a database for the client, and
finally open connections is separate threads. I guess I need to
update the ZEO docs to make this clearer.
Although there shouldn't be any harm in creating a client per thread,
it's just wasteful.
> I'm also not sure if using transaction.commit() and related calls is safe in this context.
Yes, they are. Why wouldn't they be?
>
> The function executed in each thread is
> def tickle(i):
> db = ZEO.DB(dbname)
> conn = db.open()
> if i==0:
> @transact_retry()
> def f1():
> aTree = IOBTree()
> conn.root.foo = aTree
> return aTree
> aTree = f1()
> event.set()
> else:
> event.wait()
> @transact_retry()
> def f2():
> return conn.root.foo
> aTree = f2()
> for j in range(2):
> aRun = OneRun(i+j*nThread)
> @transact_retry()
> def f3(aRun):
> aTree[aRun.num] = aRun
> f3(aRun)
> conn.close()
>
> dbname is a named pipe.
What? Do you mean a unix-domain socket? Is dbname a string?
Jim
--
Jim Fulton
http://jimfulton.info
--
You received this message because you are subscribed to the Google Groups "zodb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.