Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g7o69-0001RH-Df for psycopg@arkaria.postgresql.org; Wed, 03 Oct 2018 20:50:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g7o67-000266-AR for psycopg@arkaria.postgresql.org; Wed, 03 Oct 2018 20:50:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g7o66-00025x-Np for psycopg@lists.postgresql.org; Wed, 03 Oct 2018 20:50:19 +0000 Received: from sonic303-21.consmr.mail.ir2.yahoo.com ([77.238.178.202]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g7o63-0008HD-GH for psycopg@lists.postgresql.org; Wed, 03 Oct 2018 20:50:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1538599813; bh=2ACHh/PDNtXuF7JMn+ZnoBw23hizHzCCkXQuLHbh9L4=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=pbOye+4vcCU8X3YRM6EI7B2nAArQcY4YyXrJ5z+ri2zV4m3Y6Zie5KlJOfpcPJygNyEGUgO9MtCSjx1DFxzz/XsnpHJ684Ky+MW7psX8dopvZJCwEkgTFHcNMeC4j9gJDc4dVZ8STs6kYxfp51EpnawNS60WAeIj5EO13WKcYSp6K4tGSstujR2lrYNyUkfrg0BGfVjfPS4Y7YgHtsVWvSOTkygdhMj+8cEjAkhX5G5PCWYXuiUCuGJBL7kCXhGP866ArJAtulGtqI4SFFsbqEE8AlgL4krdaQLreyKm6VUL3rqUPhnO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ArfdbAGliERdrHIrqdr996yGZsx2FqewANXSa0 RdVxhjyBLR5JShrtT Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ir2.yahoo.com with HTTP; Wed, 3 Oct 2018 20:50:13 +0000 Date: Wed, 3 Oct 2018 20:50:08 +0000 (UTC) From: Christian Ferrari Reply-To: Christian Ferrari To: Daniele Varrazzo , Federico Di Gregorio Cc: psycopg@lists.postgresql.org Message-ID: <69747703.5400338.1538599809000@mail.yahoo.com> In-Reply-To: References: <2001056273.7945904.1537909025251.ref@mail.yahoo.com> <2001056273.7945904.1537909025251@mail.yahoo.com> <1171000727.19526618.1537994198139@mail.yahoo.com> <2038369023.20583382.1538078255866@mail.yahoo.com> <106450562.4254785.1538510870700@mail.yahoo.com> <4d647279-19ae-75ea-83a7-b74b647c79bd@dndg.it> Subject: Re: Integration of Psycopg with XTA MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5400337_594430527.1538599808999" X-Mailer: WebService/1.1.12512 YMailNorrin Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0 Content-Length: 6147 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_5400337_594430527.1538599808999 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/03/2018 02:52 PM, Daniele Varrazzo wrote: > On Wed, Oct 3, 2018 at 1:44 PM Federico Di Gregorio=C2=A0 wr= ote: >> On 10/03/2018 02:37 PM, Daniele Varrazzo wrote: >>> On Wed, Oct 3, 2018 at 1:28 PM Federico Di Gregorio=C2=A0 = wrote: >>> >>>>> This is interesting because PyCapsule is for sure a "clean" way to pa= ss >>>>> the pointer from Psycopg to XTA. >>> Fog, maybe it's worth adding the capsules for PGconn and PGresult to >>> the objects interface and document them? Can do that for psycopg 2.8. >> If it works I'd add it (and document it as an "internal" extension point >> used by other C-level modules) for 2.8, yes. >> >> By PGresult you mean adding it on the cursor, or the connection? > Yes, i'd say a _pgconn attribute or _get_pgconn() method on the > connection, a _pgresult thing on the cursor. >=20 > By the way a read-only attribute as per your implementation seems > appropriate to me. Christian, why do you think a function would be > better? > I guess the capsule is meant to be consumed by the other API and using a= =20 > method makes is explicit that a new object is instantiated every time. I= =20 > 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 sugge= stions about "Python style".In oo context, typically I expect to call a met= hod when I need to retrieve something, that's why I proposed a method inste= ad of a property.Anyway, my obscure question was related to garbage collect= ion: who is in charge of destroying the capsule and how it must be destroye= d?Looking at this example: pgconn =3D xx._get_pgconn()do_something(pgconn)pgconn =3D yy._get_pgconn() will the first capsule be automatically destroyed by the Python runtime whe= n pgconn is assigned to another one (yy....)? Or some explicit statement mu= st be executed? If everything is automatically managed by the Python runtime, I will be ver= y happy. If "do_something()" must release the capsule to avoid memory leaks= , I have to implement it. I will be very happy to test a "release candidate" version of the feature a= nd link next LIXA/XTA release with psycopg 2.8. K.R.Ch.F. =20 ------=_Part_5400337_594430527.1538599808999 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On= 10/03/2018 02:52 PM, Daniele Varrazzo wrote:
> On Wed, Oct 3, 2018 at 1:44 PM Federico Di Gregorio<fog@dndg.it>  wrote:
>> On 10/03/2018= 02:37 PM, Daniele Varrazzo wrote:
>>> On Wed, O= ct 3, 2018 at 1:28 PM Federico Di Gregorio<fog@dndg.it>&nbs= p; wrote:
>>>
>>>>= ;> This is interesting because PyCapsule is for sure a "clean" way to pa= ss
>>>>> the pointer from Psycopg to XTA.<= br clear=3D"none">>>> Fog, maybe it's worth adding the capsules fo= r PGconn and PGresult to
>>> the objects interfa= ce and document them? Can do that for psycopg 2.8.
>&g= t; If it works I'd add it (and document it as an "internal" extension point=
>> used by other C-level modules) for 2.8, yes.>>
>> By PGresult you mean ad= ding it on the cursor, or the connection?
> Yes, i'd s= ay a _pgconn attribute or _get_pgconn() method on the
>= ; connection, a _pgresult thing on the cursor.
>
> By the way a read-only attribute as per your implementat= ion seems
> appropriate to me. Christian, why do you t= hink a function would be
> better?
<= br clear=3D"none">> I guess the capsule is meant to be consumed by the o= ther API and using a
> method makes is explicit that = a new object is instantiated every time. I
> really d= on't care about this, let's do whatever is more Pythonic.

Dear Daniele & Federico,
I'm not a "pyth= onist" 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 ch= arge of destroying the capsule and how it must be destroyed?
Look= ing at this example:

pgconn =3D xx._get_pgconn()
do_something(pgconn)
pgconn =3D yy._get_pgconn()

will the first capsule be automatically destroyed by the = Python runtime when pgconn is assigned to another one (yy....)? Or some exp= licit statement must be executed?
If everything is automatica= lly 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.

I will be very happy to test a "release candida= te" version of the feature and link next LIXA/XTA release with psycopg 2.8.=

K.R.
Ch.F.



------=_Part_5400337_594430527.1538599808999--