Output cache is full, cull the oldest entries
(self)
| 285 | self.finish_displayhook() |
| 286 | |
| 287 | def cull_cache(self): |
| 288 | """Output cache is full, cull the oldest entries""" |
| 289 | oh = self.shell.user_ns.get('_oh', {}) |
| 290 | sz = len(oh) |
| 291 | cull_count = max(int(sz * self.cull_fraction), 2) |
| 292 | warn('Output cache limit (currently {sz} entries) hit.\n' |
| 293 | 'Flushing oldest {cull_count} entries.'.format(sz=sz, cull_count=cull_count)) |
| 294 | |
| 295 | for i, n in enumerate(sorted(oh)): |
| 296 | if i >= cull_count: |
| 297 | break |
| 298 | self.shell.user_ns.pop('_%i' % n, None) |
| 299 | oh.pop(n, None) |
| 300 | |
| 301 | def flush(self): |
| 302 | if not self.do_full_cache: |
no test coverage detected