PGChannelListener
Polls for NOTIFY event from postgres on a given channel and puts received notifications into a result queue.
Class Documenation
- 
class gdbpool.channel_listener.PGChannelListener(q, pool, channel_name)[source]
 
Bases: object
A Listener for Postgres LISTEN/NOTIFY channels using gevent.
For each channel there will be one PGChannelListener instance that fans
notifications out to the subscribed Queue
Create a Listener for a channel_name and pass the notifications to q result Queue.
| Parameters: | 
- q (gevent.Queue) – Queue to pass asynchronous payloads to
 
- pool (gDBPool.DBConnectionPool) – Connection pool to get a connection from and execute LISTEN <channel_name>; on if no other instance listens on that channel already. In the latter case the q is just being subscribed to the channel.
 
- channel_name (string) – channel to listen on. (LISTEN <channel_name>;)
 
 
 | 
| Return type: | PGChannelListener 
 | 
| Returns: | The PGChannelListener instance handling the channel 
 | 
- 
listen(unmarshaller=<function pipe_colon_unmarshall at 0x29a52a8>)[source]
 
Subscribe to the channel and send notification payloads to the
results Queue.
| Parameters: | unmarshaller (function) – Function to pass the notify.payload string into for unmarshalling into python object (ie. dict) data | 
- 
unregister_queue(q_id)[source]
 
Unregister a Queue from its channel.
If it was the last subscriber stop listening on the channel and put the connection used back onto the pool.
| Parameters: | q_id – The id() of the Queue to be unsubscribed from the channel | 
- 
gdbpool.channel_listener.pipe_colon_unmarshall(payload_string)[source]
 
Convert a pipe seperated string of <key:value> pairs to a dict
| Parameters: | payload_string (string) –  | 
| Return type: | dict | 
| Returns: | unmarshalled NOTIFY data |