diff options
| author | barryp@macbook.home <barryp@macbook.home> | 2009-02-23 14:32:11 -0600 |
|---|---|---|
| committer | barryp@macbook.home <barryp@macbook.home> | 2009-02-23 14:32:11 -0600 |
| commit | 99f643bc20ea81276a4424f1a947a42a34a9053c (patch) | |
| tree | 27f63be9b8a67b868ed86760c4536d5ea5f64203 /docs | |
| parent | e59dea2fb7cea05271d5272020dcf4fb951b298d (diff) | |
| download | py-amqp-99f643bc20ea81276a4424f1a947a42a34a9053c.tar.gz | |
Add some documentation about using 'with' statements.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/overview.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/overview.txt b/docs/overview.txt index 51318f0..b735ec2 100644 --- a/docs/overview.txt +++ b/docs/overview.txt @@ -58,6 +58,24 @@ Channels have a close() method too, which doesn't affect other channels | +---------------------------------------------------------------- +Connections and Channels will close automatically when used as context +managers in 'with' statements (available in Python 2.5 or higher). +For example: + + with Connection('1.2.3.4') as conn: + with conn.channel() as ch: + # + # Do some stuff... + # + ch.basic_publish(blah, blah, blah) + + # When this point is reached, the Channel will have been + # closed for you. + + # When this point is reached, the Connection will have been + # closed for you. + + Access Tickets -------------- Before a channel can do much else, it needs an access ticket, specifying |
