Output cache is full, cull the oldest entries
(self)
| 268 | self.finish_displayhook() |
| 269 | |
| 270 | def cull_cache(self): |
| 271 | """Output cache is full, cull the oldest entries""" |
| 272 | oh = self.shell.user_ns.get('_oh', {}) |
| 273 | sz = len(oh) |
| 274 | cull_count = max(int(sz * self.cull_fraction), 2) |
| 275 | warn('Output cache limit (currently {sz} entries) hit.\n' |
| 276 | 'Flushing oldest {cull_count} entries.'.format(sz=sz, cull_count=cull_count)) |
| 277 | |
| 278 | for i, n in enumerate(sorted(oh)): |
| 279 | if i >= cull_count: |
| 280 | break |
| 281 | self.shell.user_ns.pop('_%i' % n, None) |
| 282 | oh.pop(n, None) |
| 283 | |
| 284 | |
| 285 | def flush(self): |
no test coverage detected