File tree 1 file changed +16
-12
lines changed
1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -149,20 +149,24 @@ def begin(self):
149
149
self ._maybe_await (self .tx_context .begin )
150
150
151
151
def commit (self ):
152
- if self .tx_context and self .tx_context .tx_id :
153
- self ._maybe_await (self .tx_context .commit )
154
- self .tx_context = None
155
- if self .session :
156
- self ._maybe_await (self .session_pool .release , self .session )
157
- self .session = None
152
+ try :
153
+ if self .tx_context and self .tx_context .tx_id :
154
+ self ._maybe_await (self .tx_context .commit )
155
+ self .tx_context = None
156
+ finally :
157
+ if self .session :
158
+ self ._maybe_await (self .session_pool .release , self .session )
159
+ self .session = None
158
160
159
161
def rollback (self ):
160
- if self .tx_context and self .tx_context .tx_id :
161
- self ._maybe_await (self .tx_context .rollback )
162
- self .tx_context = None
163
- if self .session :
164
- self ._maybe_await (self .session_pool .release , self .session )
165
- self .session = None
162
+ try :
163
+ if self .tx_context and self .tx_context .tx_id :
164
+ self ._maybe_await (self .tx_context .rollback )
165
+ self .tx_context = None
166
+ finally :
167
+ if self .session :
168
+ self ._maybe_await (self .session_pool .release , self .session )
169
+ self .session = None
166
170
167
171
def close (self ):
168
172
self .rollback ()
You can’t perform that action at this time.
0 commit comments