Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sn2gd-000b6n-Pf for psycopg@arkaria.postgresql.org; Sat, 07 Sep 2024 21:09:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sn2gb-004CqQ-JO for psycopg@arkaria.postgresql.org; Sat, 07 Sep 2024 21:09:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sn2ga-004Cq7-3w for psycopg@lists.postgresql.org; Sat, 07 Sep 2024 21:09:37 +0000 Received: from fout6-smtp.messagingengine.com ([103.168.172.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sn2gV-0002wA-Is for psycopg@lists.postgresql.org; Sat, 07 Sep 2024 21:09:35 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 2E34313801CC; Sat, 7 Sep 2024 17:09:30 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Sat, 07 Sep 2024 17:09:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1725743370; x=1725829770; bh=qSGxsxECq3Jpt4fG/dZpVAP32H8nAv7vaInynM7P+7w=; b= 5zg7JlPkHpYUy+W8Pzc9XlNpoPYp2BhcDOt2W29QEDTL3sefL2LFY+K8bmragGkb xNxr7Cy+o01Xq8fFRoOqNxU8lOzgt6QPcc1cjOk3c8JvS1baZexNAJniQ1N1t3aW 6Yi98NEMvAZ4VxowzmXHh+t3LBekZoI6e5aVdkQ8tjrykzbTAwkqz0H67nhtAv+U 57jharYmrOYZuVsgEjAL+VbiZvrFzDxJpHQXtt5tclLkjmJSAbdfYDH/LPkmxaLa qbvErV71O/zcwujqHzeulIrN7aOUwv7lHCE3Q5rHx+ZtR5JjcRlmB/MR8VndGBQk Cn0Vfyx90ha4WwfLwSlMlQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1725743370; x= 1725829770; bh=qSGxsxECq3Jpt4fG/dZpVAP32H8nAv7vaInynM7P+7w=; b=I WdS+PU7wUoHF4loqN0ZrA6uehuk7VqV++7zrRYofxGl6dmag99M+gB+S831/UlUU ugYIg4SjuQ9hcN86FD7u8R4Qk0zUhj6R7XHJvpSwiIicL+sEoFLUdqiAAVu1QabW FkeO3RZ3D48nEEHTMtp/i7lLewvQEe7bIf2Q2IexckdHXC8HHMQD3JJP9DxC0u/W jCiBkINruP3Fq8u2yRtLP9z163o0mm4H8Ad1qZewmCCA1r2kKVeQgE8qNAzRoJep /BtJKf+9yUcDp0bTTLp5DXLw632oRqcvnOr+OF8LI+Pdw+/q2n4RTBtyrKs+iaE6 26iPv3MoEDKEnGwCt3wdg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudeifedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddv jeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvg hrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpefhveeihfevlefffedt hedukeevfefhfedtgeeifeevteffgfefhedtffetudettdenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegr khhlrghvvghrrdgtohhmpdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuth dprhgtphhtthhopehkrghrshhtvghnrdhhihhlsggvrhhtsehgmhigrdhnvghtpdhrtghp thhtohepphhshigtohhpgheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgpdhrtg hpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Sep 2024 17:09:29 -0400 (EDT) Message-ID: <4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com> Date: Sat, 7 Sep 2024 14:09:28 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: psycopg2: proper positioning of .commit() within try: except: blocks To: Karsten Hilbert Cc: psycopg@lists.postgresql.org, python-list@python.org References: <7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com> <5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/7/24 13:45, Karsten Hilbert wrote: > Am Sat, Sep 07, 2024 at 01:03:34PM -0700 schrieb Adrian Klaver: > >> In the case you show you are doing commit() before the close() so any errors in the >> transactions will show up then. My first thought would be to wrap the commit() in a >> try/except and deal with error there. > > Right, and this was suggested elsewhere ;) > > And, yeah, the actual code is much more involved :-D > I see that. The question is does the full code you show fail? The code sample you show in your original post is doing something very different then what you show in your latest post. At this point I do not understand the exact problem we are dealing with. > > > Best, > Karsten > -- > GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- Adrian Klaver adrian.klaver@aklaver.com