Re: How to get a signal from the database when a INSERT INTO is done?

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Marti Raudsepp <marti(at)juffo(dot)org>
Cc: Andre Lopes <lopes80andre(at)gmail(dot)com>, postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to get a signal from the database when a INSERT INTO is done?
Date: 2012-02-28 15:54:57
Message-ID: CA+mi_8a433cOyPCoU82BMZN0JUfpjmOKp=Egxd7zzW3xBnshBA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Feb 28, 2012 at 3:45 PM, Marti Raudsepp <marti(at)juffo(dot)org> wrote:
> On Tue, Feb 28, 2012 at 17:41, Daniele Varrazzo
> <daniele(dot)varrazzo(at)gmail(dot)com> wrote:
>> On Tue, Feb 28, 2012 at 2:15 PM, Marti Raudsepp <marti(at)juffo(dot)org> wrote:
>>> On the Python end, you have to call psycopg2 connection.poll() method
>>> periodically or in response to select() activation
>>> There's an example here:
>>> http://initd.org/psycopg/docs/advanced.html#async-notify
>
>> Using an asynchronous IO-driven framework such as eventlet or gevent
>> you don't even need to poll the connection to look for events
>
> As mentioned above and as demonstrated in the example, select() also
> does the job. Using such a fancy framework is usually an overkill.

Yeah, the problem is usually if you have to do something else apart
from listening from the notification. select() will block the entire
application, so you would put it into a separate thread to have the
app running on. From here to start benefiting from eventlet the step
is very short. If a blocking behaviour is ok, then no problem using
bare select().

-- Daniele

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Clodoaldo Neto 2012-02-28 16:21:26 psql: invalid connection option "client_encoding"
Previous Message Marti Raudsepp 2012-02-28 15:45:08 Re: How to get a signal from the database when a INSERT INTO is done?