guild.members: use context manager for pool conn acquire

This commit is contained in:
Luna 2019-11-15 20:37:10 -03:00
parent e917982f6d
commit bc3fa37d63
1 changed files with 21 additions and 24 deletions

View File

@ -95,8 +95,7 @@ async def _update_member_roles(guild_id: int, member_id: int, wanted_roles: set)
# in wanted_roles
removed_roles = roles - wanted_roles
conn = await app.db.acquire()
async with app.db.acquire() as conn:
async with conn.transaction():
# add roles
await app.db.executemany(
@ -119,8 +118,6 @@ async def _update_member_roles(guild_id: int, member_id: int, wanted_roles: set)
[(member_id, guild_id, role_id) for role_id in removed_roles],
)
await app.db.release(conn)
@bp.route("/<int:guild_id>/members/<int:member_id>", methods=["PATCH"])
async def modify_guild_member(guild_id, member_id):