Skip to content

Commit b79e56a

Browse files
committed
typos
1 parent 9e5b10c commit b79e56a

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

README.rst

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -323,24 +323,24 @@ Publish / Subscribe
323323
^^^^^^^^^^^^^^^^^^^
324324

325325
redis-py includes a `PubSub` object that subscribes to channels and listens
326-
for new messages. Creating a `PubSub` object is easy:
326+
for new messages. Creating a `PubSub` object is easy.
327327

328328
.. code-block:: pycon
329329
330330
>>> r = redis.StrictRedis(...)
331331
>>> p = r.pubsub()
332332
333333
Once a `PubSub` instance is created, channels and patterns can be subscribed
334-
to:
334+
to.
335335

336336
.. code-block:: pycon
337337
338338
>>> p.subscribe('my-first-channel', 'my-second-channel', ...)
339339
>>> p.psubscribe('my-*', ...)
340340
341341
The `PubSub` instance is now subscribed to those channels/patterns. The
342-
subscription confirmations can be seen by reading messages off the `PubSub`
343-
instance:
342+
subscription confirmations can be seen by reading messages from the `PubSub`
343+
instance.
344344

345345
.. code-block:: pycon
346346
@@ -352,14 +352,14 @@ instance:
352352
{'pattern': None, 'type': 'psubscribe', 'channel': 'my-*', 'data': 3L}
353353
354354
Every message read from a `PubSub` instance will be a dictionary with the
355-
following keys:
355+
following keys.
356356

357357
* **type**: One of the following: 'subscribe', 'unsubscribe', 'psubscribe',
358358
'punsubscribe', 'message', 'pmessage'
359359
* **channel**: The channel [un]subscribed to or the channel a message was
360360
published to
361-
* **pattern**: The pattern that matched a published messages channel. Will be
362-
None in all cases except for 'pmessage' types.
361+
* **pattern**: The pattern that matched a published message's channel. Will be
362+
`None` in all cases except for 'pmessage' types.
363363
* **data**: The message data. With [un]subscribe messages, this value will be
364364
the number of channels and patterns the connection is currently subscribed
365365
to. With [p]message messages, this value will be the actual published
@@ -381,7 +381,7 @@ Let's send a message now.
381381
{'channel': 'my-first-channel', 'data': 'some data', 'pattern': 'my-*', 'type': 'pmessage'}
382382
383383
Unsubscribing works just like subscribing. If no arguments are passed to
384-
[p]unsubscribe, all channels or patterns will be unsubscribed from:
384+
[p]unsubscribe, all channels or patterns will be unsubscribed from.
385385

386386
.. code-block:: pycon
387387
@@ -398,17 +398,19 @@ redis-py also allows you to register callback functions to handle published
398398
messages. Message handlers take a single argument, the message, which is a
399399
dictionary just like the examples above. To subscribe to a channel or pattern
400400
with a message handler, pass the channel or pattern name as a keyword argument
401-
with a value of the callback function.
401+
with its value being the callback function.
402402

403-
When a message is read on a channels or pattern with a message handler, the
404-
message dictionary is created and passed to the message handler. A None value
405-
is returned from get_message().
403+
When a message is read on a channel or pattern with a message handler, the
404+
message dictionary is created and passed to the message handler. In this case,
405+
a `None` value is returned from get_message() since the message was already
406+
handled.
406407

407408
.. code-block:: pycon
408409
409410
>>> def my_handler(message):
410411
... print 'MY HANDLER: ', message['data']
411412
>>> p.subscribe(**{'my-channel': my_handler})
413+
# read the subscribe confirmation message
412414
>>> p.get_message()
413415
{'pattern': None, 'type': 'subscribe', 'channel': 'my-channel', 'data': 1L}
414416
>>> r.publish('my-channel', 'awesome data')
@@ -424,9 +426,10 @@ is returned from get_message().
424426
None
425427
426428
If your application is not interested in the (sometimes noisy)
427-
subscribe/unsubscribe messages, you can pass `ignore_subscribe_messages=True`
428-
to redis.pubsub(). This will cause all subscribe/unsubscribe messages to be
429-
read, but they won't bubble up to your application:
429+
subscribe/unsubscribe confirmation messages, you can ignore them by passing
430+
`ignore_subscribe_messages=True` to `r.pubsub()`. This will cause all
431+
subscribe/unsubscribe messages to be read, but they won't bubble up to your
432+
application.
430433

431434
.. code-block:: pycon
432435
@@ -445,7 +448,8 @@ The examples above have been using `pubsub.get_message()`. Behind the scenes,
445448
connection's socket. If there's data available to be read, `get_message()` will
446449
read it, format the message and return it or pass it to a message handler. If
447450
there's no data to be read, `get_message()` will immediately return None. This
448-
makes it trivial to integrate into an event loop inside your application:
451+
makes it trivial to integrate into an existing event loop inside your
452+
application.
449453

450454
.. code-block:: pycon
451455
@@ -458,7 +462,7 @@ makes it trivial to integrate into an event loop inside your application:
458462
Older versions of redis-py only read messages with `pubsub.listen()`. listen()
459463
is a generator that blocks until a message is available. If your application
460464
doesn't need to do anything else but receive and act on messages received from
461-
redis, listen() is an easy way to get up an running:
465+
redis, listen() is an easy way to get up an running.
462466

463467
.. code-block:: pycon
464468
@@ -467,7 +471,7 @@ redis, listen() is an easy way to get up an running:
467471
468472
The third option runs an event loop in a separate thread.
469473
`pubsub.run_in_thread()` creates a new thread and starts the event loop. The
470-
thread object is returned the caller of `run_in_thread()`. The caller can
474+
thread object is returned to the caller of `run_in_thread()`. The caller can
471475
use the `thread.stop()` method to shut down the event loop and thread. Behind
472476
the scenes, this is simply a wrapper around `get_message()` that runs in a
473477
separate thread, essentially creating a tiny non-blocking event loop for you.

0 commit comments

Comments
 (0)