Re: PQisBusy() always busy - Mailing list pgsql-novice

From Merlin Moncure
Subject Re: PQisBusy() always busy
Date
Msg-id CAHyXU0zzLqfOrf9t8+0cJGaJ0JiLr9apYJcnRAjhbpOy5SHzYg@mail.gmail.com
Whole thread Raw
In response to Re: PQisBusy() always busy  (bradg <bg4all@me.com>)
Responses Re: PQisBusy() always busy  (bradg <bg4all@me.com>)
List pgsql-novice
On Mon, Sep 12, 2011 at 5:44 PM, bradg <bg4all@me.com> wrote:
> I know it must sound stupid, but...
>
> My code is simple and works exactly the way I want it to with the blocking
> functions PQexecParams() and PQexecPrepared(). I'm trying to extend it with
> asynchronous functions so I can execute queries both ways.
>
> But I seem to be losing a lot of time on this so my thought was to just use
> the blocking functions in a separate thread. Hence my question whether or
> not they are thread safe.
>
> Do you know if they are?

I reiterate that it is dangerous to use threads unless you have a very
good reason to do so.  It makes everything more complex: debugging,
logging, etc. Feel free to try it, but...

libpq is thread safe if so compiled but it is your responsibility to
ensure that only one thread accesses a connection object at once.  Hm.
You *are* aware that with asynchronous connections you must fully
retrieve a result before sending the next query?  The asynchronous
model is generally meant for keeping multiple connection objects with
each having at most one running query.  It also allows for low latency
processing of asynchronous notification events coming back from the
server, keeping the process under your control so you can respond to
user UI actions, etc.

merlin

pgsql-novice by date:

Previous
From: Tony Theodore
Date:
Subject: Re: Using expression names in subsequent calculation
Next
From: Julien
Date:
Subject: Drop multiple roles