Re: so, is connection.poll() supposed to block?

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Croepha <croepha(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: so, is connection.poll() supposed to block?
Date: 2011-10-04 17:11:07
Message-ID: CA+mi_8YHGpZKMBmnW6-Rc4QgV+EscTtej_FnWzsHv_QsaeCsbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Tue, Oct 4, 2011 at 5:21 PM, Croepha <croepha(at)gmail(dot)com> wrote:

> I just wan't to verify my understanding of how psycopg2 works:
> 1. Can synchronous connections can block on poll?

Likely. Just to start, you call functions on a libpq connection that
hasn't set in nonblocking mode. I'd leave what happens in the realm of
the undefined.

> 2. Are you allowed to set client encoding in an asynchronous connection?
> (mine gives me an exception when I try) if not, why not?

No, you are not, it is documented among the shortcomings of async
connections <http://initd.org/psycopg/docs/advanced.html#async-support>.
The reason is that every query requires to be "pumped" manually to the
database and the result pumped back, so we allow the user to do that
on the query they run via execute(), but specifically forbid any
method that would send a query behind the scene, which otherwise would
require the same treatment.

You can set the env variable PGCLIENTENCODING or use
client_encoding=BLAH in the connection string at connection time, not
change it afterwards.

-- Daniele

In response to

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2011-10-05 13:26:54 psycopg, pgpool and closing connections
Previous Message Croepha 2011-10-04 16:21:38 Re: so, is connection.poll() supposed to block?