Re: PQisBusy() always busy

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: bradg <bg4all(at)me(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: PQisBusy() always busy
Date: 2011-09-13 15:12:29
Message-ID: CAHyXU0zzLqfOrf9t8+0cJGaJ0JiLr9apYJcnRAjhbpOy5SHzYg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Mon, Sep 12, 2011 at 5:44 PM, bradg <bg4all(at)me(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Julien 2011-09-13 15:40:24 Drop multiple roles
Previous Message Tony Theodore 2011-09-13 07:49:06 Re: Using expression names in subsequent calculation