1
0
Fork 0
mirror of synced 2024-06-21 12:00:16 +12:00

Ensured that the connection closes when saving and getting data

This commit is contained in:
phxntxm 2016-08-30 21:19:19 -05:00
parent 6f9acb0d7a
commit 65d4b143b3
2 changed files with 3 additions and 0 deletions

View file

@ -27,6 +27,7 @@ class Tags:
tags = await config.get_content('tags')
# Same generator as the method for tags, other than the second check to get the tag that is provided
result = [t for t in tags if t['tag'] == tag and t['server_id'] == ctx.message.server.id]
print("Tags: {}\nAmount of tags: {}".format(tags, len(tags)))
if len(result) == 0:
await self.bot.say('That tag does not exist!')
return

View file

@ -118,7 +118,9 @@ async def get_content(key: str):
cursor = await r.table(key).run(conn)
items = list(cursor.items)[0]
except (IndexError, r.ReqlOpFailedError):
await conn.close()
return {}
# Rethink db stores an internal id per table, delete this and return the rest
del items['id']
conn.close()
return items