|
|
|
|
|
by wulczer
4600 days ago
|
|
Why can't you use a connection that has issued LISTEN for anything else? In fact, I'm fairly sure you can use it normally. We're using NOTIFY to broadcast database changes to services that should react to them and it's quite a nice way to separate concerns: process A just writes to the database, a trigger issues a NOTIFY, process B checks and notices there's been a change. Edit: I see, the code in the post suggests that the connection needs to be stuck in a select() (I should know, I contributed a largre chunk of psycopg2's async code handling). You just need to use an asynchronous driver and you can happily LISTEN and do queries at the same time (of course you won't get notifies while a query is processing - the Postgres protocol has no concept of multiplexing). We're using Twisted and happily mixing queries and NOTIFY. |
|