Обсуждение: so, is connection.poll() supposed to block?
It seems to be blocking, (or waiting on IO at times...) What is the point to doing a select on the connection if poll is going to block?
Thanks
On Sat, Oct 1, 2011 at 9:18 AM, Croepha <croepha@gmail.com> wrote: > It seems to be blocking, (or waiting on IO at times...) What is the point to > doing a select on the connection if poll is going to block? Have you vented? Ok, great. Now, care to provide an example of what you're talking about? -- Daniele
On 01/10/11 10:41, Daniele Varrazzo wrote: > On Sat, Oct 1, 2011 at 9:18 AM, Croepha <croepha@gmail.com> wrote: >> > It seems to be blocking, (or waiting on IO at times...) What is the point to >> > doing a select on the connection if poll is going to block? > Have you vented? Ok, great. Now, care to provide an example of what > you're talking about? He's probably polling a synchronous connection. federico -- Federico Di Gregorio fog@initd.org When people say things are a lot more complicated than that, they means they're getting worried that they won't like the truth. -- Granny Weatherwax
On Mon, Oct 3, 2011 at 3:18 AM, Federico Di Gregorio <fog@dndg.it> wrote:
He's probably polling a synchronous connection.On 01/10/11 10:41, Daniele Varrazzo wrote:
> On Sat, Oct 1, 2011 at 9:18 AM, Croepha <croepha@gmail.com> wrote:
>> > It seems to be blocking, (or waiting on IO at times...) What is the point to
>> > doing a select on the connection if poll is going to block?
> Have you vented? Ok, great. Now, care to provide an example of what
> you're talking about?
I am currently using a synchronous connection.
I just wan't to verify my understanding of how psycopg2 works:
1. Can synchronous connections can block on poll?
2. Are you allowed to set client encoding in an asynchronous connection? (mine gives me an exception when I try) if not, why not?
PS:
Sorry, I just now realized that I had replied directly to Daniele, instead of posting to the list
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