Re: NOTIFY in asynchronous mode

From: Tobias Oberstein <tobias(dot)oberstein(at)tavendo(dot)de>
To: Jan Urbański <wulczer(at)wulczer(dot)org>, Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Re: NOTIFY in asynchronous mode
Date: 2011-11-05 10:30:23
Message-ID: 634914A010D0B943A035D226786325D42D0C0CE423@EXVMBX020-12.exch020.serverdata.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

> >> is it possible to use notification (sent via NOTIFY from Postgres) in
> asynchronous mode?
> >
> > Yes: you should register the connection's file descriptor in the
> > twisted reactor so that you can be notified by the kernel when the
> > server sends you a notification.
>
> Actually... it won't work out of the box. I got a patch from someone that
> added NOTIFY support for txpostgres, but it broke some unit tests and there
> were a few other minor issues with it and then I kind of forgot about it.
>
> Recently I've been picking up txpostgres' development and I might add
> NOTIFY support soon, maybe even the next week.

That would be marvelous!

>
> The problem with it now is that when there's no query going on, the
> connection's descriptor is not present in the reactor, it only gets added for
> the duration of the query. Once I figure out how to change that without
> breaking some subtle corner cases, you'll be able to register a NOTIFY

Sounds intricate .. if there is something how I could help, let me know ..

> callback that will get called when there's an async notification received by the
> connection.

What would be provided to the callback?

Channel (from NOTIFIY), Payload (from NOTIFIY), Connection (txpostgres) ?

>
> Cheers,
> Jan

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Jan Urbański 2011-11-05 10:47:37 Re: NOTIFY in asynchronous mode
Previous Message Jan Urbański 2011-11-05 00:21:34 Re: NOTIFY in asynchronous mode