Re: so, is connection.poll() supposed to block? - Mailing list psycopg

From Daniele Varrazzo
Subject Re: so, is connection.poll() supposed to block?
Date
Msg-id CA+mi_8YHGpZKMBmnW6-Rc4QgV+EscTtej_FnWzsHv_QsaeCsbA@mail.gmail.com
Whole thread Raw
In response to Re: so, is connection.poll() supposed to block?  (Croepha <croepha@gmail.com>)
List psycopg
On Tue, Oct 4, 2011 at 5:21 PM, Croepha <croepha@gmail.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

psycopg by date:

Previous
From: Croepha
Date:
Subject: Re: so, is connection.poll() supposed to block?
Next
From: Daniele Varrazzo
Date:
Subject: psycopg, pgpool and closing connections