Fix README example code.
This commit is contained in:
		| @@ -46,6 +46,7 @@ Note that this requires `git` to be installed. | |||||||
|  |  | ||||||
| ```py | ```py | ||||||
| import discord | import discord | ||||||
|  | import asyncio | ||||||
|  |  | ||||||
| client = discord.Client() | client = discord.Client() | ||||||
|  |  | ||||||
| @@ -76,8 +77,12 @@ def main_task(): | |||||||
|     yield from client.connect() |     yield from client.connect() | ||||||
|  |  | ||||||
| loop = asyncio.get_event_loop() | loop = asyncio.get_event_loop() | ||||||
| loop.run_until_complete(main_task()) | try: | ||||||
| loop.close() |     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. | You can find examples in the examples directory. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user