Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit 83bacbd

Browse files
committed
Fixed broken pipeline examples. Fixes #384
1 parent dcb5358 commit 83bacbd

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

docs/pipelines.rst

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,21 @@ This code does NOT wrap `MULTI/EXEC` around the commands when packed
107107
.. code-block:: python
108108
109109
>>> from rediscluster import RedisCluster as s
110+
110111
>>> r = s(startup_nodes=[{"host": "127.0.0.1", "port": "7002"}])
112+
111113
>>> # Simulate that a slot is migrating to another node
112-
>>> r.connection_pool.nodes.slots[14226] = {'host': '127.0.0.1', 'server_type': 'master', 'port': 7001, 'name': '127.0.0.1:7001'}
114+
>>> r.connection_pool.nodes.slots[14226] = [{
115+
>>> 'host': '127.0.0.1',
116+
>>> 'server_type': 'master',
117+
>>> 'port': 7001,
118+
>>> 'name': '127.0.0.1:7001',
119+
>>> }]
120+
113121
>>> p = r.pipeline()
114-
>>> p.command_stack = []
115-
>>> p.command_stack.append((["SET", "ert", "tre"], {}))
116-
>>> p.command_stack.append((["SET", "wer", "rew"], {}))
117-
>>> p.execute()
122+
>>> p.set('ert', 'tre')
123+
>>> p.set('wer', 'rew')
124+
>>> print(p.execute())
118125
119126
ClusterConnection<host=127.0.0.1,port=7001>
120127
[True, ResponseError('MOVED 14226 127.0.0.1:7002',)]
@@ -126,14 +133,22 @@ This code DO wrap MULTI/EXEC around the commands when packed
126133
.. code-block:: python
127134
128135
>>> from rediscluster import RedisCluster as s
136+
129137
>>> r = s(startup_nodes=[{"host": "127.0.0.1", "port": "7002"}])
138+
130139
>>> # Simulate that a slot is migrating to another node
131-
>>> r.connection_pool.nodes.slots[14226] = {'host': '127.0.0.1', 'server_type': 'master', 'port': 7001, 'name': '127.0.0.1:7001'}
140+
>>> r.connection_pool.nodes.slots[14226] = [{
141+
>>> 'host': '127.0.0.1',
142+
>>> 'server_type': 'master',
143+
>>> 'port': 7001,
144+
>>> 'name': '127.0.0.1:7001',
145+
>>> }]
146+
132147
>>> p = r.pipeline()
133-
>>> p.command_stack = []
134-
>>> p.command_stack.append((["SET", "ert", "tre"], {}))
135-
>>> p.command_stack.append((["SET", "wer", "rew"], {}))
136-
>>> p.execute()
148+
>>> p.set('ert', 'tre')
149+
>>> p.set('wer', 'rew')
150+
>>> print(p.execute())
151+
137152
ClusterConnection<host=127.0.0.1,port=7001>
138153
[True, False]
139154

0 commit comments

Comments
 (0)