Ensured that the connection closes when saving and getting data
This commit is contained in:
parent
6f9acb0d7a
commit
65d4b143b3
|
@ -27,6 +27,7 @@ class Tags:
|
||||||
tags = await config.get_content('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
|
# 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]
|
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:
|
if len(result) == 0:
|
||||||
await self.bot.say('That tag does not exist!')
|
await self.bot.say('That tag does not exist!')
|
||||||
return
|
return
|
||||||
|
|
|
@ -118,7 +118,9 @@ async def get_content(key: str):
|
||||||
cursor = await r.table(key).run(conn)
|
cursor = await r.table(key).run(conn)
|
||||||
items = list(cursor.items)[0]
|
items = list(cursor.items)[0]
|
||||||
except (IndexError, r.ReqlOpFailedError):
|
except (IndexError, r.ReqlOpFailedError):
|
||||||
|
await conn.close()
|
||||||
return {}
|
return {}
|
||||||
# Rethink db stores an internal id per table, delete this and return the rest
|
# Rethink db stores an internal id per table, delete this and return the rest
|
||||||
del items['id']
|
del items['id']
|
||||||
|
conn.close()
|
||||||
return items
|
return items
|
||||||
|
|
Loading…
Reference in a new issue