|
15 | 15 | from redis.commands.helpers import list_or_args
|
16 | 16 | from redis.connection import ConnectionPool, DefaultParser, parse_url
|
17 | 17 | from redis.crc import REDIS_CLUSTER_HASH_SLOTS, key_slot
|
18 |
| -from redis.event import EventDispatcher, EventDispatcherInterface, AfterPooledConnectionsInstantiationEvent, ClientType |
| 18 | +from redis.event import EventDispatcher, EventDispatcherInterface, AfterPooledConnectionsInstantiationEvent, ClientType, \ |
| 19 | + AfterPubSubConnectionInstantiationEvent |
19 | 20 | from redis.exceptions import (
|
20 | 21 | AskError,
|
21 | 22 | AuthenticationError,
|
@@ -1714,6 +1715,7 @@ def __init__(
|
1714 | 1715 | host=None,
|
1715 | 1716 | port=None,
|
1716 | 1717 | push_handler_func=None,
|
| 1718 | + event_dispatcher: Optional["EventDispatcher"] = EventDispatcher(), |
1717 | 1719 | **kwargs,
|
1718 | 1720 | ):
|
1719 | 1721 | """
|
@@ -1743,6 +1745,7 @@ def __init__(
|
1743 | 1745 | connection_pool=connection_pool,
|
1744 | 1746 | encoder=redis_cluster.encoder,
|
1745 | 1747 | push_handler_func=push_handler_func,
|
| 1748 | + event_dispatcher=event_dispatcher, |
1746 | 1749 | **kwargs,
|
1747 | 1750 | )
|
1748 | 1751 |
|
@@ -1829,6 +1832,14 @@ def execute_command(self, *args):
|
1829 | 1832 | self.connection.register_connect_callback(self.on_connect)
|
1830 | 1833 | if self.push_handler_func is not None and not HIREDIS_AVAILABLE:
|
1831 | 1834 | self.connection._parser.set_pubsub_push_handler(self.push_handler_func)
|
| 1835 | + self.event_dispatcher.dispatch( |
| 1836 | + AfterPubSubConnectionInstantiationEvent( |
| 1837 | + self.connection, |
| 1838 | + self.connection_pool, |
| 1839 | + ClientType.SYNC, |
| 1840 | + self._lock |
| 1841 | + ) |
| 1842 | + ) |
1832 | 1843 | connection = self.connection
|
1833 | 1844 | self._execute(connection, connection.send_command, *args)
|
1834 | 1845 |
|
|
0 commit comments