Skip to content

Commit

Permalink
Merge pull request #8 from octaflop/doc-update
Browse files Browse the repository at this point in the history
updated docs, updated gitignore
  • Loading branch information
andrewgodwin committed Sep 10, 2015
2 parents d563f77 + 414a4ab commit 10df1c2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.egg-info
dist/
docs/_build
__pycache__/
*.swp

2 changes: 1 addition & 1 deletion channels/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def run(self):
except Message.Requeue:
self.channel_backend.send(channel, content)
except:
print "Error processing message with consumer %s:" % name_that_thing(consumer)
print("Error processing message with consumer {}:".format(name_that_thing(consumer)))
traceback.print_exc()
4 changes: 2 additions & 2 deletions docs/concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The channels have capacity, so a load of producers can write lots of messages
into a channel with no consumers and then a consumer can come along later and
will start getting served those queued messages.

If you've used channels in Go, these are reasonably similar to those. The key
If you've used `channels in Go <https://gobyexample.com/channels>`_, these are reasonably similar to those. The key
difference is that these channels are network-transparent; the implementations
of channels we provide are all accessible across a network to consumers
and producers running in different processes or on different machines.
Expand Down Expand Up @@ -161,7 +161,7 @@ and be less than 200 characters long.

It's optional for a backend implementation to understand this - after all,
it's only important at scale, where you want to shard the two types differently
- but it's present nonetheless. For more on scaling, and how to handle channel
but it's present nonetheless. For more on scaling, and how to handle channel
types if you're writing a backend or interface server, read :doc:`scaling`.

Groups
Expand Down
6 changes: 6 additions & 0 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ do any time. Let's try some WebSockets, and make a basic chat server!
Delete that consumer and its routing - we'll want the normal Django view layer to
serve HTTP requests from now on - and make this WebSocket consumer instead::

from channels import Group

def ws_add(message):
Group("chat").add(message.reply_channel)

Expand Down Expand Up @@ -105,6 +107,8 @@ so we can hook that up to re-add the channel (it's safe to add the channel to
a group it's already in - similarly, it's safe to discard a channel from a
group it's not in)::

from channels import Group

# Connected to websocket.keepalive
def ws_keepalive(message):
Group("chat").add(message.reply_channel)
Expand All @@ -123,6 +127,8 @@ And, even though channels will expire out, let's add an explicit ``disconnect``
handler to clean up as people disconnect (most channels will cleanly disconnect
and get this called)::

from channels import Group

# Connected to websocket.disconnect
def ws_disconnect(message):
Group("chat").discard(message.reply_channel)
Expand Down
13 changes: 13 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@ Once that's done, you should add ``channels`` to your

That's it! Once enabled, ``channels`` will integrate itself into Django and
take control of the ``runserver`` command. See :doc:`getting-started` for more.


Installing the lastest development version
------------------------------------------

To install the latest version of Channels, clone the repo, change to the repo,
change to the repo directory, and pip install it into your current virtual
environment::

$ git clone git@github.com:andrewgodwin/channels.git
$ cd channels
$ <activate your project’s virtual environment>
(environment) $ pip install -e . # the dot specifies the current repo
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
license='BSD',
packages=find_packages(),
include_package_data=True,
install_requires=[
'six',
]
)

0 comments on commit 10df1c2

Please sign in to comment.