1083 # this is not expected to break anything that happen during the hooks. |
1083 # this is not expected to break anything that happen during the hooks. |
1084 tr.addfinalize('flush-fncache', self.store.write) |
1084 tr.addfinalize('flush-fncache', self.store.write) |
1085 def txnclosehook(tr2): |
1085 def txnclosehook(tr2): |
1086 """To be run if transaction is successful, will schedule a hook run |
1086 """To be run if transaction is successful, will schedule a hook run |
1087 """ |
1087 """ |
|
1088 # Don't reference tr2 in hook() so we don't hold a reference. |
|
1089 # This reduces memory consumption when there are multiple |
|
1090 # transactions per lock. This can likely go away if issue5045 |
|
1091 # fixes the function accumulation. |
|
1092 hookargs = tr2.hookargs |
|
1093 |
1088 def hook(): |
1094 def hook(): |
1089 reporef().hook('txnclose', throw=False, txnname=desc, |
1095 reporef().hook('txnclose', throw=False, txnname=desc, |
1090 **tr2.hookargs) |
1096 **hookargs) |
1091 reporef()._afterlock(hook) |
1097 reporef()._afterlock(hook) |
1092 tr.addfinalize('txnclose-hook', txnclosehook) |
1098 tr.addfinalize('txnclose-hook', txnclosehook) |
1093 def txnaborthook(tr2): |
1099 def txnaborthook(tr2): |
1094 """To be run if transaction is aborted |
1100 """To be run if transaction is aborted |
1095 """ |
1101 """ |