public inbox for [email protected]
help / color / mirror / Atom feedFrom: Federico Di Gregorio <[email protected]>
To: [email protected]
Subject: Re: Integration of Psycopg with XTA
Date: Thu, 4 Oct 2018 11:32:35 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<CA+mi_8a5Sm=Zum+8uRX+gDLrzzEU+F-x5xjommxL5e7jLBxHkg@mail.gmail.com>
<[email protected]>
<CA+mi_8bZ-hxA2DTshOh15b1GdbET8+EVO5eh9N2qyyfvDgXKCw@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<CA+mi_8YBz5GZRJfqj3Jr+gA4tpR7yd1aYXiPGQU9Sb7hiXJPfA@mail.gmail.com>
<[email protected]>
<CA+mi_8aTsj2d+kyrz+86ZOZ8Srno0T5Px6w+SWqfw5iiSPBkcA@mail.gmail.com>
<[email protected]>
<[email protected]>
On 10/03/2018 10:50 PM, Christian Ferrari wrote:
[snip]
> > I guess the capsule is meant to be consumed by the other API and using a
> > method makes is explicit that a new object is instantiated every time. I
> > really don't care about this, let's do whatever is more Pythonic.
>
> Dear Daniele & Federico,
> I'm not a "pythonist" at all, I can't provide suggestions about "Python
> style".
> In oo context, typically I expect to call a method when I need to
> retrieve something, that's why I proposed a method instead of a property.
> Anyway, my obscure question was related to garbage collection: who is in
> charge of destroying the capsule and how it must be destroyed?
> Looking at this example:
>
> pgconn = xx._get_pgconn()
> do_something(pgconn)
> pgconn = yy._get_pgconn()
>
> will the first capsule be automatically destroyed by the Python runtime
> when pgconn is assigned to another one (yy....)? Or some explicit
> statement must be executed?
> If everything is automatically managed by the Python runtime, I will be
> very happy. If "do_something()" must release the capsule to avoid memory
> leaks, I have to implement it.
The capsule is a standard reference-counted Python object. If the API
just use the pointer inside it and does not keep a reference to the
Python object itself, it will be free'd by the gc when the reference
count goes to 0. In your example, the first capsule is garbage collected
when you assign the second one to the same variable "pgconn".
@Daniele, I see that a capsule has an implicit state, "invalid" if the
pointer inside it is null. Does it makes sense to reuse the same capsule
and keep a reference to it to be able to invalidate it when the
connection is closed?
federico
--
Federico Di Gregorio [email protected]
DNDG srl http://dndg.it
The only thing I see is if you are pumping so much data into the
database all the time when do you expect to look at it?
-- Charlie Clark
view thread (22+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Integration of Psycopg with XTA
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox