Re: advisability of closing long-running ZEO connection

Jim Fulton <[email protected]>
Newsgroups gmane.comp.web.zope.zodb
Message-ID <CAPDm-Fik=Xrfv5PDAht09VQJrYZ=H3im3TXP4pEdOwCRw3tA=w@mail.gmail.com>
On Thu, Nov 10, 2016 at 12:21 PM, Boylan, Ross <[email protected]> wrote:

> Thanks for your response. See below in blue:
> ------------------------------
> *From:* [email protected] [[email protected]] on behalf of Jim Fulton [
> [email protected]]
> *Sent:* Thursday, November 10, 2016 6:40 AM
> *To:* Boylan, Ross
> *Cc:* zodb ‎[[email protected]]‎
> *Subject:* Re: [ZODB] advisability of closing long-running ZEO connection
>
> I assume/hope that your subject is erroneous.  I assume you're referring
> to ZODB connections, not ZEO connections.
>
> From the client I do
> db = ZEO.DB(dbname)
> and then, in each thread,
> conn = db.open()
>

OK, so my assumption is correct. These are ZODB connections, not ZEO
connections.



> On Wed, Nov 9, 2016 at 3:56 PM, Boylan, Ross <[email protected]> wrote:
>
>> My application sets up a lot of objects and the does a commit, with ZEO
>> providing the backend.
>> It then runs a lot of computations in threads, each of which updates the
>> data at the start and the end of the computation.
>>
>
> Do these computations use the database data while the computations are
> underway?
> No.  The computation threads just spawn off a SAS process and wait for it
> to finish.
>

OK. Unless the updates at the beginning and end need to be in the same
transaction, I'd recommend opening a connection to make each change and
then closing it after the commit. In other words, at the beginning of the
thread, open a connection, do whatever and then close it. Then at the end
of the thread, open a new connection for that work. But I don't really know
what you're doing so I may be off base.



> My application's main thread does nothing during this time except launch
>> new threads, and all the information it needs is in the objects as of the
>> first commit.
>>
>> Is it safe to close the connection in the main thread during this time?
>> My concern is that some of the objects I need may dematerialize if I do so
>> (or perhaps might have been dematerialized while the connection was open).
>>
>
> You should **never** hold on to objects from closed connections.
> That's what I needed to know.
>

Cool.

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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.