async def transaction():
pool = await aioredis.create_pool('redis://localhost')
with await pool as con:
await con.execute('multi')
await con.execute('watch', 'var')
raise Exception
上述事务是通过连接池上下文安全释放的吗?
async def transaction():
pool = await aioredis.create_pool('redis://localhost')
with await pool as con:
try:
await con.execute('multi')
await con.execute('watch')
raise Exception
except Exception as e:
await con.execute('discard')
否则,我应该明确地放弃交易吗?