Commit 5d1df96
committed
tests: clear util.callback_mgr between test cases
util.callback_mgr.callbacks was not getting properly cleared between tests.
Every time an Abstract_Wallet or an LNWorker (or many other subclasses of EventListener) is instantiated,
self.register_callbacks() is called in __init__, which puts callbacks into util.callback_mgr.callbacks.
These are only cleaned up if we explicitly call Abstract_Wallet.stop() or LNWorker.stop() later, which we usually do not do in the tests.
As a result, when running multiple unit tests in a row, lots of objects created in a given testcase are never GC-ed and leak into subsequent tests. This is not only a memory leak, but wastes compute too: when events are triggered and cbs get called, these old objects also have their cbs called.
After running all (~1061) unit tests, I observe util.callback_mgr.callbacks had 30 events with a total of 3156 callbacks stored.
On my laptop, running all unit tests previously took ~115 sec, and now it takes ~73 sec.1 parent fd0ad25 commit 5d1df96
3 files changed
+13
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1953 | 1953 | | |
1954 | 1954 | | |
1955 | 1955 | | |
1956 | | - | |
| 1956 | + | |
1957 | 1957 | | |
1958 | | - | |
| 1958 | + | |
1959 | 1959 | | |
1960 | 1960 | | |
1961 | 1961 | | |
1962 | 1962 | | |
1963 | | - | |
| 1963 | + | |
1964 | 1964 | | |
1965 | 1965 | | |
1966 | 1966 | | |
1967 | 1967 | | |
1968 | 1968 | | |
1969 | | - | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
1970 | 1974 | | |
1971 | 1975 | | |
1972 | 1976 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1117 | 1117 | | |
1118 | 1118 | | |
1119 | 1119 | | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
| 1120 | + | |
| 1121 | + | |
1126 | 1122 | | |
1127 | 1123 | | |
1128 | 1124 | | |
| |||
1191 | 1187 | | |
1192 | 1188 | | |
1193 | 1189 | | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
| 1190 | + | |
| 1191 | + | |
1200 | 1192 | | |
1201 | 1193 | | |
1202 | 1194 | | |
| |||
0 commit comments