| 49 | return self._generation |
| 50 | |
| 51 | def release(self, generation): |
| 52 | with self._lock: |
| 53 | if generation != self._generation: |
| 54 | return |
| 55 | if self._active_engines == 0: |
| 56 | return |
| 57 | self._active_engines -= 1 |
| 58 | restore_enabled = self._active_engines == 0 and self._restore_enabled |
| 59 | if self._active_engines == 0: |
| 60 | self._restore_enabled = False |
| 61 | if restore_enabled and not gc.isenabled(): |
| 62 | gc.enable() |
| 63 | logger.info("Restored automatic Python cyclic GC") |
| 64 | |
| 65 | def collect(self): |
| 66 | """Run an explicit collection without changing the automatic-GC policy.""" |