We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
aioredis.pubsub.Receiver has no iter() method
The example code (below) references an iter() method on Receiver (here is the [implementation](https://github.com/aio-libs/aioredis/blob/master/aioredis/pubsub.py#L200)).

There is no iter() method on Receiver. What is the correct implementation of listening on all Receiver's subscribed channels?

code:
```
>>> from aioredis.pubsub import Receiver
>>> from aioredis.abc import AbcChannel
>>> mpsc = Receiver(loop=loop)
>>> async def reader(mpsc):
...     async for channel, msg in mpsc.iter():
...         assert isinstance(channel, AbcChannel)
...         print("Got {!r} in channel {!r}".format(msg, channel))
>>> asyncio.ensure_future(reader(mpsc))
>>> await redis.subscribe(mpsc.channel('channel:1'),
...                       mpsc.channel('channel:3'))
...                       mpsc.channel('channel:5'))
>>> await redis.psubscribe(mpsc.pattern('hello'))
>>> # publishing 'Hello world' into 'hello-channel'
>>> # will print this message:
Got b'Hello world' in channel b'hello-channel'
>>> # when all is done:
>>> await redis.unsubscribe('channel:1', 'channel:3', 'channel:5')
>>> await redis.punsubscribe('hello')
>>> mpsc.stop()
>>> # any message received after stop() will be ignored.
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `aioredis/commands/__init__.py`
Content:
```
1 import asyncio
2 import warnings
3 
4 from aioredis.connection import create_connection
5 from aioredis.pool import create_pool
6 from aioredis.util import _NOTSET
7 from .generic import GenericCommandsMixin
8 from .string import StringCommandsMixin
9 from .hash import HashCommandsMixin
10 from .hyperloglog import HyperLogLogCommandsMixin
11 from .set import SetCommandsMixin
12 from .sorted_set import SortedSetCommandsMixin
13 from .transaction import TransactionsCommandsMixin, Pipeline, MultiExec
14 from .list import ListCommandsMixin
15 from .scripting import ScriptingCommandsMixin
16 from .server import ServerCommandsMixin
17 from .pubsub import PubSubCommandsMixin
18 from .cluster import ClusterCommandsMixin
19 from .geo import GeoCommandsMixin, GeoPoint, GeoMember
20 
21 __all__ = [
22     'create_redis',
23     'create_redis_pool',
24     'Redis',
25     'Pipeline',
26     'MultiExec',
27     'GeoPoint',
28     'GeoMember',
29 ]
30 
31 
32 class Redis(GenericCommandsMixin, StringCommandsMixin,
33             HyperLogLogCommandsMixin, SetCommandsMixin,
34             HashCommandsMixin, TransactionsCommandsMixin,
35             SortedSetCommandsMixin, ListCommandsMixin,
36             ScriptingCommandsMixin, ServerCommandsMixin,
37             PubSubCommandsMixin, ClusterCommandsMixin,
38             GeoCommandsMixin):
39     """High-level Redis interface.
40 
41     Gathers in one place Redis commands implemented in mixins.
42 
43     For commands details see: http://redis.io/commands/#connection
44     """
45     def __init__(self, pool_or_conn):
46         self._pool_or_conn = pool_or_conn
47 
48     def __repr__(self):
49         return '<Redis {!r}>'.format(self._pool_or_conn)
50 
51     def execute(self, command, *args, **kwargs):
52         return self._pool_or_conn.execute(command, *args, **kwargs)
53 
54     def close(self):
55         """Close client connections."""
56         self._pool_or_conn.close()
57 
58     @asyncio.coroutine
59     def wait_closed(self):
60         """Coroutine waiting until underlying connections are closed."""
61         yield from self._pool_or_conn.wait_closed()
62 
63     @property
64     def db(self):
65         """Currently selected db index."""
66         return self._pool_or_conn.db
67 
68     @property
69     def encoding(self):
70         """Current set codec or None."""
71         return self._pool_or_conn.encoding
72 
73     @property
74     def connection(self):
75         """Either :class:`aioredis.RedisConnection`,
76         or :class:`aioredis.ConnectionsPool` instance.
77         """
78         return self._pool_or_conn
79 
80     @property
81     def address(self):
82         """Redis connection address (if applicable)."""
83         return self._pool_or_conn.address
84 
85     @property
86     def in_transaction(self):
87         """Set to True when MULTI command was issued."""
88         # XXX: this must be bound to real connection
89         return self._pool_or_conn.in_transaction
90 
91     @property
92     def closed(self):
93         """True if connection is closed."""
94         return self._pool_or_conn.closed
95 
96     def auth(self, password):
97         """Authenticate to server.
98 
99         This method wraps call to :meth:`aioredis.RedisConnection.auth()`
100         """
101         return self._pool_or_conn.auth(password)
102 
103     def echo(self, message, *, encoding=_NOTSET):
104         """Echo the given string."""
105         return self.execute('ECHO', message, encoding=encoding)
106 
107     def ping(self, message=_NOTSET, *, encoding=_NOTSET):
108         """Ping the server.
109 
110         Accept optional echo message.
111         """
112         if message is not _NOTSET:
113             args = (message,)
114         else:
115             args = ()
116         return self.execute('PING', *args, encoding=encoding)
117 
118     def quit(self):
119         """Close the connection."""
120         # TODO: warn when using pool
121         return self.execute('QUIT')
122 
123     def select(self, db):
124         """Change the selected database for the current connection.
125 
126         This method wraps call to :meth:`aioredis.RedisConnection.select()`
127         """
128         return self._pool_or_conn.select(db)
129 
130     def __enter__(self):
131         # TODO: warn it is obsolete way
132         warnings.warn("It is not recommended way to use Redis instance"
133                       " as a context manager. Use Redis.<command> directly")
134         return self
135 
136     def __exit__(self, *args):
137         pass
138 
139     def __iter__(self):
140         return self
141         yield
142 
143 
144 @asyncio.coroutine
145 def create_redis(address, *, db=None, password=None, ssl=None,
146                  encoding=None, commands_factory=Redis,
147                  parser=None, timeout=None,
148                  connection_cls=None, loop=None):
149     """Creates high-level Redis interface.
150 
151     This function is a coroutine.
152     """
153     conn = yield from create_connection(address, db=db,
154                                         password=password,
155                                         ssl=ssl,
156                                         encoding=encoding,
157                                         parser=parser,
158                                         timeout=timeout,
159                                         connection_cls=connection_cls,
160                                         loop=loop)
161     return commands_factory(conn)
162 
163 
164 @asyncio.coroutine
165 def create_redis_pool(address, *, db=None, password=None, ssl=None,
166                       encoding=None, commands_factory=Redis,
167                       minsize=1, maxsize=10, parser=None,
168                       timeout=None, pool_cls=None,
169                       connection_cls=None, loop=None):
170     """Creates high-level Redis interface.
171 
172     This function is a coroutine.
173     """
174     pool = yield from create_pool(address, db=db,
175                                   password=password,
176                                   ssl=ssl,
177                                   encoding=encoding,
178                                   minsize=minsize,
179                                   maxsize=maxsize,
180                                   parser=parser,
181                                   create_connection_timeout=timeout,
182                                   pool_cls=pool_cls,
183                                   connection_cls=connection_cls,
184                                   loop=loop)
185     return commands_factory(pool)
186
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/aioredis/commands/__init__.py b/aioredis/commands/__init__.py
--- a/aioredis/commands/__init__.py
+++ b/aioredis/commands/__init__.py
@@ -1,9 +1,10 @@
 import asyncio
-import warnings
+# import warnings
 
 from aioredis.connection import create_connection
 from aioredis.pool import create_pool
 from aioredis.util import _NOTSET
+from aioredis.abc import AbcPool
 from .generic import GenericCommandsMixin
 from .string import StringCommandsMixin
 from .hash import HashCommandsMixin
@@ -46,7 +47,7 @@
         self._pool_or_conn = pool_or_conn
 
     def __repr__(self):
-        return '<Redis {!r}>'.format(self._pool_or_conn)
+        return '<{} {!r}>'.format(self.__class__.__name__, self._pool_or_conn)
 
     def execute(self, command, *args, **kwargs):
         return self._pool_or_conn.execute(command, *args, **kwargs)
@@ -127,18 +128,38 @@
         """
         return self._pool_or_conn.select(db)
 
+    def __await__(self):
+        if isinstance(self._pool_or_conn, AbcPool):
+            conn = yield from self._pool_or_conn.acquire()
+            release = self._pool_or_conn.release
+        else:
+            # TODO: probably a lock is needed here if _pool_or_conn
+            #       is Connection instance.
+            conn = self._pool_or_conn
+            release = None
+        return ContextRedis(conn, release)
+    __iter__ = __await__
+
+
+class ContextRedis(Redis):
+    """An instance of Redis class bound to single connection."""
+
+    def __init__(self, conn, release_cb=None):
+        super().__init__(conn)
+        self._release_callback = release_cb
+
     def __enter__(self):
-        # TODO: warn it is obsolete way
-        warnings.warn("It is not recommended way to use Redis instance"
-                      " as a context manager. Use Redis.<command> directly")
         return self
 
-    def __exit__(self, *args):
-        pass
+    def __exit__(self, *exc_info):
+        if self._release_callback is not None:
+            conn, self._pool_or_conn = self._pool_or_conn, None
+            self._release_callback(conn)
 
-    def __iter__(self):
-        return self
+    def __await__(self):
+        return ContextRedis(self._pool_or_conn)
         yield
+    __iter__ = __await__
 
 
 @asyncio.coroutine

{"golden_diff": "diff --git a/aioredis/commands/__init__.py b/aioredis/commands/__init__.py\n--- a/aioredis/commands/__init__.py\n+++ b/aioredis/commands/__init__.py\n@@ -1,9 +1,10 @@\n import asyncio\n-import warnings\n+# import warnings\n \n from aioredis.connection import create_connection\n from aioredis.pool import create_pool\n from aioredis.util import _NOTSET\n+from aioredis.abc import AbcPool\n from .generic import GenericCommandsMixin\n from .string import StringCommandsMixin\n from .hash import HashCommandsMixin\n@@ -46,7 +47,7 @@\n         self._pool_or_conn = pool_or_conn\n \n     def __repr__(self):\n-        return '<Redis {!r}>'.format(self._pool_or_conn)\n+        return '<{} {!r}>'.format(self.__class__.__name__, self._pool_or_conn)\n \n     def execute(self, command, *args, **kwargs):\n         return self._pool_or_conn.execute(command, *args, **kwargs)\n@@ -127,18 +128,38 @@\n         \"\"\"\n         return self._pool_or_conn.select(db)\n \n+    def __await__(self):\n+        if isinstance(self._pool_or_conn, AbcPool):\n+            conn = yield from self._pool_or_conn.acquire()\n+            release = self._pool_or_conn.release\n+        else:\n+            # TODO: probably a lock is needed here if _pool_or_conn\n+            #       is Connection instance.\n+            conn = self._pool_or_conn\n+            release = None\n+        return ContextRedis(conn, release)\n+    __iter__ = __await__\n+\n+\n+class ContextRedis(Redis):\n+    \"\"\"An instance of Redis class bound to single connection.\"\"\"\n+\n+    def __init__(self, conn, release_cb=None):\n+        super().__init__(conn)\n+        self._release_callback = release_cb\n+\n     def __enter__(self):\n-        # TODO: warn it is obsolete way\n-        warnings.warn(\"It is not recommended way to use Redis instance\"\n-                      \" as a context manager. Use Redis.<command> directly\")\n         return self\n \n-    def __exit__(self, *args):\n-        pass\n+    def __exit__(self, *exc_info):\n+        if self._release_callback is not None:\n+            conn, self._pool_or_conn = self._pool_or_conn, None\n+            self._release_callback(conn)\n \n-    def __iter__(self):\n-        return self\n+    def __await__(self):\n+        return ContextRedis(self._pool_or_conn)\n         yield\n+    __iter__ = __await__\n \n \n @asyncio.coroutine\n", "issue": "aioredis.pubsub.Receiver has no iter() method\nThe example code (below) references an iter() method on Receiver (here is the [implementation](https://github.com/aio-libs/aioredis/blob/master/aioredis/pubsub.py#L200)).\r\n\r\nThere is no iter() method on Receiver. What is the correct implementation of listening on all Receiver's subscribed channels?\r\n\r\ncode:\r\n```\r\n>>> from aioredis.pubsub import Receiver\r\n>>> from aioredis.abc import AbcChannel\r\n>>> mpsc = Receiver(loop=loop)\r\n>>> async def reader(mpsc):\r\n...     async for channel, msg in mpsc.iter():\r\n...         assert isinstance(channel, AbcChannel)\r\n...         print(\"Got {!r} in channel {!r}\".format(msg, channel))\r\n>>> asyncio.ensure_future(reader(mpsc))\r\n>>> await redis.subscribe(mpsc.channel('channel:1'),\r\n...                       mpsc.channel('channel:3'))\r\n...                       mpsc.channel('channel:5'))\r\n>>> await redis.psubscribe(mpsc.pattern('hello'))\r\n>>> # publishing 'Hello world' into 'hello-channel'\r\n>>> # will print this message:\r\nGot b'Hello world' in channel b'hello-channel'\r\n>>> # when all is done:\r\n>>> await redis.unsubscribe('channel:1', 'channel:3', 'channel:5')\r\n>>> await redis.punsubscribe('hello')\r\n>>> mpsc.stop()\r\n>>> # any message received after stop() will be ignored.\r\n```\n", "before_files": [{"content": "import asyncio\nimport warnings\n\nfrom aioredis.connection import create_connection\nfrom aioredis.pool import create_pool\nfrom aioredis.util import _NOTSET\nfrom .generic import GenericCommandsMixin\nfrom .string import StringCommandsMixin\nfrom .hash import HashCommandsMixin\nfrom .hyperloglog import HyperLogLogCommandsMixin\nfrom .set import SetCommandsMixin\nfrom .sorted_set import SortedSetCommandsMixin\nfrom .transaction import TransactionsCommandsMixin, Pipeline, MultiExec\nfrom .list import ListCommandsMixin\nfrom .scripting import ScriptingCommandsMixin\nfrom .server import ServerCommandsMixin\nfrom .pubsub import PubSubCommandsMixin\nfrom .cluster import ClusterCommandsMixin\nfrom .geo import GeoCommandsMixin, GeoPoint, GeoMember\n\n__all__ = [\n    'create_redis',\n    'create_redis_pool',\n    'Redis',\n    'Pipeline',\n    'MultiExec',\n    'GeoPoint',\n    'GeoMember',\n]\n\n\nclass Redis(GenericCommandsMixin, StringCommandsMixin,\n            HyperLogLogCommandsMixin, SetCommandsMixin,\n            HashCommandsMixin, TransactionsCommandsMixin,\n            SortedSetCommandsMixin, ListCommandsMixin,\n            ScriptingCommandsMixin, ServerCommandsMixin,\n            PubSubCommandsMixin, ClusterCommandsMixin,\n            GeoCommandsMixin):\n    \"\"\"High-level Redis interface.\n\n    Gathers in one place Redis commands implemented in mixins.\n\n    For commands details see: http://redis.io/commands/#connection\n    \"\"\"\n    def __init__(self, pool_or_conn):\n        self._pool_or_conn = pool_or_conn\n\n    def __repr__(self):\n        return '<Redis {!r}>'.format(self._pool_or_conn)\n\n    def execute(self, command, *args, **kwargs):\n        return self._pool_or_conn.execute(command, *args, **kwargs)\n\n    def close(self):\n        \"\"\"Close client connections.\"\"\"\n        self._pool_or_conn.close()\n\n    @asyncio.coroutine\n    def wait_closed(self):\n        \"\"\"Coroutine waiting until underlying connections are closed.\"\"\"\n        yield from self._pool_or_conn.wait_closed()\n\n    @property\n    def db(self):\n        \"\"\"Currently selected db index.\"\"\"\n        return self._pool_or_conn.db\n\n    @property\n    def encoding(self):\n        \"\"\"Current set codec or None.\"\"\"\n        return self._pool_or_conn.encoding\n\n    @property\n    def connection(self):\n        \"\"\"Either :class:`aioredis.RedisConnection`,\n        or :class:`aioredis.ConnectionsPool` instance.\n        \"\"\"\n        return self._pool_or_conn\n\n    @property\n    def address(self):\n        \"\"\"Redis connection address (if applicable).\"\"\"\n        return self._pool_or_conn.address\n\n    @property\n    def in_transaction(self):\n        \"\"\"Set to True when MULTI command was issued.\"\"\"\n        # XXX: this must be bound to real connection\n        return self._pool_or_conn.in_transaction\n\n    @property\n    def closed(self):\n        \"\"\"True if connection is closed.\"\"\"\n        return self._pool_or_conn.closed\n\n    def auth(self, password):\n        \"\"\"Authenticate to server.\n\n        This method wraps call to :meth:`aioredis.RedisConnection.auth()`\n        \"\"\"\n        return self._pool_or_conn.auth(password)\n\n    def echo(self, message, *, encoding=_NOTSET):\n        \"\"\"Echo the given string.\"\"\"\n        return self.execute('ECHO', message, encoding=encoding)\n\n    def ping(self, message=_NOTSET, *, encoding=_NOTSET):\n        \"\"\"Ping the server.\n\n        Accept optional echo message.\n        \"\"\"\n        if message is not _NOTSET:\n            args = (message,)\n        else:\n            args = ()\n        return self.execute('PING', *args, encoding=encoding)\n\n    def quit(self):\n        \"\"\"Close the connection.\"\"\"\n        # TODO: warn when using pool\n        return self.execute('QUIT')\n\n    def select(self, db):\n        \"\"\"Change the selected database for the current connection.\n\n        This method wraps call to :meth:`aioredis.RedisConnection.select()`\n        \"\"\"\n        return self._pool_or_conn.select(db)\n\n    def __enter__(self):\n        # TODO: warn it is obsolete way\n        warnings.warn(\"It is not recommended way to use Redis instance\"\n                      \" as a context manager. Use Redis.<command> directly\")\n        return self\n\n    def __exit__(self, *args):\n        pass\n\n    def __iter__(self):\n        return self\n        yield\n\n\n@asyncio.coroutine\ndef create_redis(address, *, db=None, password=None, ssl=None,\n                 encoding=None, commands_factory=Redis,\n                 parser=None, timeout=None,\n                 connection_cls=None, loop=None):\n    \"\"\"Creates high-level Redis interface.\n\n    This function is a coroutine.\n    \"\"\"\n    conn = yield from create_connection(address, db=db,\n                                        password=password,\n                                        ssl=ssl,\n                                        encoding=encoding,\n                                        parser=parser,\n                                        timeout=timeout,\n                                        connection_cls=connection_cls,\n                                        loop=loop)\n    return commands_factory(conn)\n\n\n@asyncio.coroutine\ndef create_redis_pool(address, *, db=None, password=None, ssl=None,\n                      encoding=None, commands_factory=Redis,\n                      minsize=1, maxsize=10, parser=None,\n                      timeout=None, pool_cls=None,\n                      connection_cls=None, loop=None):\n    \"\"\"Creates high-level Redis interface.\n\n    This function is a coroutine.\n    \"\"\"\n    pool = yield from create_pool(address, db=db,\n                                  password=password,\n                                  ssl=ssl,\n                                  encoding=encoding,\n                                  minsize=minsize,\n                                  maxsize=maxsize,\n                                  parser=parser,\n                                  create_connection_timeout=timeout,\n                                  pool_cls=pool_cls,\n                                  connection_cls=connection_cls,\n                                  loop=loop)\n    return commands_factory(pool)\n", "path": "aioredis/commands/__init__.py"}], "after_files": [{"content": "import asyncio\n# import warnings\n\nfrom aioredis.connection import create_connection\nfrom aioredis.pool import create_pool\nfrom aioredis.util import _NOTSET\nfrom aioredis.abc import AbcPool\nfrom .generic import GenericCommandsMixin\nfrom .string import StringCommandsMixin\nfrom .hash import HashCommandsMixin\nfrom .hyperloglog import HyperLogLogCommandsMixin\nfrom .set import SetCommandsMixin\nfrom .sorted_set import SortedSetCommandsMixin\nfrom .transaction import TransactionsCommandsMixin, Pipeline, MultiExec\nfrom .list import ListCommandsMixin\nfrom .scripting import ScriptingCommandsMixin\nfrom .server import ServerCommandsMixin\nfrom .pubsub import PubSubCommandsMixin\nfrom .cluster import ClusterCommandsMixin\nfrom .geo import GeoCommandsMixin, GeoPoint, GeoMember\n\n__all__ = [\n    'create_redis',\n    'create_redis_pool',\n    'Redis',\n    'Pipeline',\n    'MultiExec',\n    'GeoPoint',\n    'GeoMember',\n]\n\n\nclass Redis(GenericCommandsMixin, StringCommandsMixin,\n            HyperLogLogCommandsMixin, SetCommandsMixin,\n            HashCommandsMixin, TransactionsCommandsMixin,\n            SortedSetCommandsMixin, ListCommandsMixin,\n            ScriptingCommandsMixin, ServerCommandsMixin,\n            PubSubCommandsMixin, ClusterCommandsMixin,\n            GeoCommandsMixin):\n    \"\"\"High-level Redis interface.\n\n    Gathers in one place Redis commands implemented in mixins.\n\n    For commands details see: http://redis.io/commands/#connection\n    \"\"\"\n    def __init__(self, pool_or_conn):\n        self._pool_or_conn = pool_or_conn\n\n    def __repr__(self):\n        return '<{} {!r}>'.format(self.__class__.__name__, self._pool_or_conn)\n\n    def execute(self, command, *args, **kwargs):\n        return self._pool_or_conn.execute(command, *args, **kwargs)\n\n    def close(self):\n        \"\"\"Close client connections.\"\"\"\n        self._pool_or_conn.close()\n\n    @asyncio.coroutine\n    def wait_closed(self):\n        \"\"\"Coroutine waiting until underlying connections are closed.\"\"\"\n        yield from self._pool_or_conn.wait_closed()\n\n    @property\n    def db(self):\n        \"\"\"Currently selected db index.\"\"\"\n        return self._pool_or_conn.db\n\n    @property\n    def encoding(self):\n        \"\"\"Current set codec or None.\"\"\"\n        return self._pool_or_conn.encoding\n\n    @property\n    def connection(self):\n        \"\"\"Either :class:`aioredis.RedisConnection`,\n        or :class:`aioredis.ConnectionsPool` instance.\n        \"\"\"\n        return self._pool_or_conn\n\n    @property\n    def address(self):\n        \"\"\"Redis connection address (if applicable).\"\"\"\n        return self._pool_or_conn.address\n\n    @property\n    def in_transaction(self):\n        \"\"\"Set to True when MULTI command was issued.\"\"\"\n        # XXX: this must be bound to real connection\n        return self._pool_or_conn.in_transaction\n\n    @property\n    def closed(self):\n        \"\"\"True if connection is closed.\"\"\"\n        return self._pool_or_conn.closed\n\n    def auth(self, password):\n        \"\"\"Authenticate to server.\n\n        This method wraps call to :meth:`aioredis.RedisConnection.auth()`\n        \"\"\"\n        return self._pool_or_conn.auth(password)\n\n    def echo(self, message, *, encoding=_NOTSET):\n        \"\"\"Echo the given string.\"\"\"\n        return self.execute('ECHO', message, encoding=encoding)\n\n    def ping(self, message=_NOTSET, *, encoding=_NOTSET):\n        \"\"\"Ping the server.\n\n        Accept optional echo message.\n        \"\"\"\n        if message is not _NOTSET:\n            args = (message,)\n        else:\n            args = ()\n        return self.execute('PING', *args, encoding=encoding)\n\n    def quit(self):\n        \"\"\"Close the connection.\"\"\"\n        # TODO: warn when using pool\n        return self.execute('QUIT')\n\n    def select(self, db):\n        \"\"\"Change the selected database for the current connection.\n\n        This method wraps call to :meth:`aioredis.RedisConnection.select()`\n        \"\"\"\n        return self._pool_or_conn.select(db)\n\n    def __await__(self):\n        if isinstance(self._pool_or_conn, AbcPool):\n            conn = yield from self._pool_or_conn.acquire()\n            release = self._pool_or_conn.release\n        else:\n            # TODO: probably a lock is needed here if _pool_or_conn\n            #       is Connection instance.\n            conn = self._pool_or_conn\n            release = None\n        return ContextRedis(conn, release)\n    __iter__ = __await__\n\n\nclass ContextRedis(Redis):\n    \"\"\"An instance of Redis class bound to single connection.\"\"\"\n\n    def __init__(self, conn, release_cb=None):\n        super().__init__(conn)\n        self._release_callback = release_cb\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, *exc_info):\n        if self._release_callback is not None:\n            conn, self._pool_or_conn = self._pool_or_conn, None\n            self._release_callback(conn)\n\n    def __await__(self):\n        return ContextRedis(self._pool_or_conn)\n        yield\n    __iter__ = __await__\n\n\n@asyncio.coroutine\ndef create_redis(address, *, db=None, password=None, ssl=None,\n                 encoding=None, commands_factory=Redis,\n                 parser=None, timeout=None,\n                 connection_cls=None, loop=None):\n    \"\"\"Creates high-level Redis interface.\n\n    This function is a coroutine.\n    \"\"\"\n    conn = yield from create_connection(address, db=db,\n                                        password=password,\n                                        ssl=ssl,\n                                        encoding=encoding,\n                                        parser=parser,\n                                        timeout=timeout,\n                                        connection_cls=connection_cls,\n                                        loop=loop)\n    return commands_factory(conn)\n\n\n@asyncio.coroutine\ndef create_redis_pool(address, *, db=None, password=None, ssl=None,\n                      encoding=None, commands_factory=Redis,\n                      minsize=1, maxsize=10, parser=None,\n                      timeout=None, pool_cls=None,\n                      connection_cls=None, loop=None):\n    \"\"\"Creates high-level Redis interface.\n\n    This function is a coroutine.\n    \"\"\"\n    pool = yield from create_pool(address, db=db,\n                                  password=password,\n                                  ssl=ssl,\n                                  encoding=encoding,\n                                  minsize=minsize,\n                                  maxsize=maxsize,\n                                  parser=parser,\n                                  create_connection_timeout=timeout,\n                                  pool_cls=pool_cls,\n                                  connection_cls=connection_cls,\n                                  loop=loop)\n    return commands_factory(pool)\n", "path": "aioredis/commands/__init__.py"}]}