aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-12-20 01:47:02 -0500
committerRapptz <[email protected]>2015-12-20 01:47:02 -0500
commitca450fb0e44fc303a2c319e2fe53920714d7551e (patch)
tree9feb51b823e6a1f95793200689e5d766183b654a
parentAdd guessing game example to showcase wait_for_message. (diff)
downloaddiscord.py-ca450fb0e44fc303a2c319e2fe53920714d7551e.tar.xz
discord.py-ca450fb0e44fc303a2c319e2fe53920714d7551e.zip
Fix README example code.
-rw-r--r--README.md9
1 files changed, 7 insertions, 2 deletions
diff --git a/README.md b/README.md
index 92d5e9d7..365a33ab 100644
--- a/README.md
+++ b/README.md
@@ -46,6 +46,7 @@ Note that this requires `git` to be installed.
```py
import discord
+import asyncio
client = discord.Client()
@@ -76,8 +77,12 @@ def main_task():
yield from client.connect()
loop = asyncio.get_event_loop()
-loop.run_until_complete(main_task())
-loop.close()
+try:
+ loop.run_until_complete(main_task())
+except Exception:
+ loop.run_until_complete(client.close())
+finally:
+ loop.close()
```
You can find examples in the examples directory.