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 1l9oqh-0008MP-Ck for psycopg@arkaria.postgresql.org; Wed, 10 Feb 2021 12:44:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l9oqe-0004zy-Lq for psycopg@arkaria.postgresql.org; Wed, 10 Feb 2021 12:44:00 +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 1l9oqe-0004zr-Eu for psycopg@lists.postgresql.org; Wed, 10 Feb 2021 12:44:00 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l9oqX-0002Ym-FE for psycopg@postgresql.org; Wed, 10 Feb 2021 12:43:59 +0000 Received: by mail-lf1-x129.google.com with SMTP id p21so2601868lfu.11 for ; Wed, 10 Feb 2021 04:43:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HiQRu2Lx3jeQbbYgnDEKDkHCjU4HOIe44Ijha95sct0=; b=ixIyMLnyXx5lCWkodMKtwRLVrCSYdQnwR0bFrmTsPuJ/NQfDGyvWXFgv6k9H/tPIiC Od18cKq/QKK3t9v7/vFZjztrLUqsRIRtwgl0BllQ4jJe+he8aVBQ1+EwmLCQHjvvc5G0 EvY9Ge5fp1UqFSY2qZqjOlpLGxxY2kCsDOcRYog9bnjX6kds7PkIGsGT7QkUFDj+mSbd Zxosn0HKThN9MrIq2+e1xLX4xC0o/W+R62UGvYA9OmkmHlnrLTGZF2DTDDd+vQPmrBMs Q2L1UyYIzFytSDCQgTvvPOWFhVGYdA4EDQ9WWds7S5tKyj/5eiYr1oICVXre96NCE5nZ 46NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HiQRu2Lx3jeQbbYgnDEKDkHCjU4HOIe44Ijha95sct0=; b=BqK9KM19sjUtOR4J5OIdLG7IATVMSUrWgZaWnDFrYoZcskYBT1BY5LZyvZGVVn77xc cKPnfcwrEcEqPAGkaZX0ejyIzvlukBehimc3IF2QUb18X6zGfL9MCsubkxyHEhtTHgs8 Qq6A4hZPUrrKdeDTzeDHweMPFyEXMFzW6gJ9bkXozK5AumWgPPmZGXs1sby4cClPMkY7 heb+uPvdAhzEzYNRh6qHxu2B6sA6qusPA9jbIi9OoQBRt2Hg5F7U/KL+InXhYcfcUGnf kqkkSCqf4uyVTNoolBIMbdq0nC4l4kVxeqEjZGLCmV8iI4FDwOAqlmKo7u3YOpsxvIQt XAHQ== X-Gm-Message-State: AOAM533VwVXQdRsIB/DuwM7x9+yHKyUs+rzg76HBSSgUNfEZg/OPjr+h q6QWAYA8W7aA7Un5YkSdpilwt7G+8MGUON7WsNqqqRaOIZeh+A== X-Google-Smtp-Source: ABdhPJw8YBZyzBloTEihEaZUSQTPaWYQu6xeZvdZcxYo1JjJW9gnFu8aQNU1N/6iL50iYdSniov90yZhz22FFmZppMk= X-Received: by 2002:a05:6512:74:: with SMTP id i20mr1631789lfo.37.1612961031576; Wed, 10 Feb 2021 04:43:51 -0800 (PST) MIME-Version: 1.0 References: <20210203161548.vkhu3qkpvmgvyhik@dalibo.com> In-Reply-To: <20210203161548.vkhu3qkpvmgvyhik@dalibo.com> From: Daniele Varrazzo Date: Wed, 10 Feb 2021 13:43:39 +0100 Message-ID: Subject: Re: about client-side cursors To: Denis Laxalde Cc: psycopg@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, 3 Feb 2021 at 17:16, Denis Laxalde wrote: > Why do we need two 'await' (i.e. two IO operations) on conn.execute() > and cur.fetchall() if 'cur' is a client-side cursor? (Back to my first > point about where IO happen, this appears to depend on whether the > connection has 'autocommit' or not...) Around this point, one arguably not useful `await` is on `connection.cursor()`. I wanted to put some flesh around server-side cursors before making my mind around it. Now I have, as I am working in a server-side cursor branch, and I don't think there are reasonable cases where `connection.cursor()` might do I/O. So, in the server-side branch, I've made the function non-async on AsyncConnection too. This makes also context manager better to use, as now you can do: async with aconn.cursor() as cur: # use it whereas previously it would have taken an `async with await aconn.cursor()`. I assume the change is welcome, but please let me know if this is not the case. Cheers -- Daniele