Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7iTZ-0004tZ-Pr for psycopg@arkaria.postgresql.org; Thu, 04 Feb 2021 17:31:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l7iTY-0002ic-Jp for psycopg@arkaria.postgresql.org; Thu, 04 Feb 2021 17:31:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7iTY-0002iV-Eo for psycopg@lists.postgresql.org; Thu, 04 Feb 2021 17:31:28 +0000 Received: from smtp85.iad3b.emailsrvr.com ([146.20.161.85]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l7iTW-0000K4-1v for psycopg@postgresql.org; Thu, 04 Feb 2021 17:31:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=g001.emailsrvr.com; s=20190322-9u7zjiwi; t=1612459884; bh=8yw7fJQLrO7U4IWxjSGkdCABCildJP0SMrndFsq5Eow=; h=Subject:From:Date:To:From; b=yWYu22EJa/yCZyTg7Oy7jPKRVjXg51rlxSUkOz04ue1V+gtK/upfGebeEIx75Qahw jCC6pSCEa1fYjmXtlv9wAdlUdakUff3eW3q3NBlPRC65HClDUWd3G4uKXEs5JXrdyv P9zSNdEHksiTbDKll5hQTHIqDMmSs5NcY9/y/jP8= X-Auth-ID: xof@thebuild.com Received: by smtp3.relay.iad3b.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id 41526402A7; Thu, 4 Feb 2021 12:31:24 -0500 (EST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.7\)) Subject: Re: about client-side cursors From: Christophe Pettus In-Reply-To: <20210204172135.bl2boudpyw4vfahv@dalibo.com> Date: Thu, 4 Feb 2021 09:31:22 -0800 Cc: Daniele Varrazzo , psycopg@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20210203161548.vkhu3qkpvmgvyhik@dalibo.com> <20210204111647.4s3qie5cnassksa5@dalibo.com> <20210204172135.bl2boudpyw4vfahv@dalibo.com> To: Denis Laxalde X-Mailer: Apple Mail (2.3445.9.7) X-Classification-ID: e6921cd4-3d4d-4072-9fb0-a3e1c1aff235-1-1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Feb 4, 2021, at 09:21, Denis Laxalde = wrote: >=20 > Well, maybe I'm missing something... In the examples above, (written > down explicitly to understand where IO happens), if I shut down = postgres > between 'await conn.execute()' and 'await cur.fetchall()', the first > example breaks but the second doesn't. Perhaps the autocommit mention > was misleading; it's enough to insert 'await conn.commit()' before > 'await cur.fetchall()' to reproduce. So (and again, unless I'm missing > something), if this is not "by design", maybe this is bug? You're relying on private knowledge, not an API guarantee, as to "where = I/O happens" here. Like any expectation based on private knowledge, you = can get tripped up by that. We shouldn't write into the API contract that either cursor.execute() or = cursor.fetch*() are guaranteed not to fail with an I/O error. Any time = you interact with the cursor object, that can be assumed to be an = asynchronous operation that can fail due to the remote server not being = available. Knowing that, you can reasonably code defensively no matter = what. Adding those explicit guarantees about I/O to the API hugely limits = underlying implementation changes in the future, for as far as I can = tell no real gain. If it comes down to "cursor isn't a good name for this class," that's = probably true, but we're a decade past making that decision. > As far as the async interface is concerned, I think there is no = adoption > issue because there's no precedent use from psycopg2. So we could > expose two API: cursorless querying ('await conn.execute()') and have = a > single server-side cursor class. Right now, switching from using just a client-side cursor object to = server-side cursor preserves largely preserves the API. I think that's = a valuable feature that's worth retaining. -- -- Christophe Pettus xof@thebuild.com