Perform any cleanup actions in the logging system (e.g. flushing buffers). Should be called at application exit.
(handlerList=_handlerList)
| 2168 | root.manager._clear_cache() |
| 2169 | |
| 2170 | def shutdown(handlerList=_handlerList): |
| 2171 | """ |
| 2172 | Perform any cleanup actions in the logging system (e.g. flushing |
| 2173 | buffers). |
| 2174 | |
| 2175 | Should be called at application exit. |
| 2176 | """ |
| 2177 | for wr in reversed(handlerList[:]): |
| 2178 | #errors might occur, for example, if files are locked |
| 2179 | #we just ignore them if raiseExceptions is not set |
| 2180 | try: |
| 2181 | h = wr() |
| 2182 | if h: |
| 2183 | try: |
| 2184 | h.acquire() |
| 2185 | h.flush() |
| 2186 | h.close() |
| 2187 | except (OSError, ValueError): |
| 2188 | # Ignore errors which might be caused |
| 2189 | # because handlers have been closed but |
| 2190 | # references to them are still around at |
| 2191 | # application exit. |
| 2192 | pass |
| 2193 | finally: |
| 2194 | h.release() |
| 2195 | except: # ignore everything, as we're shutting down |
| 2196 | if raiseExceptions: |
| 2197 | raise |
| 2198 | #else, swallow |
| 2199 | |
| 2200 | #Let's try and shutdown automatically on application exit... |
| 2201 | import atexit |