diff options
Diffstat (limited to 'examples/background_task.py')
| -rw-r--r-- | examples/background_task.py | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/examples/background_task.py b/examples/background_task.py index 38dbf482..c1e4c7e2 100644 --- a/examples/background_task.py +++ b/examples/background_task.py @@ -19,13 +19,5 @@ async def on_ready(): print(client.user.id) print('------') -loop = asyncio.get_event_loop() - -try: - loop.create_task(my_background_task()) - loop.run_until_complete(client.login('token')) - loop.run_until_complete(client.connect()) -except Exception: - loop.run_until_complete(client.close()) -finally: - loop.close() +client.loop.create_task(my_background_task()) +client.run('token') |